Browse code

Updated OMAP support

Adds updated TI code (under the OMAP_ENHANCEMENT conditional) for
compatibility with the current version of OMAP3/OMAP4 kernel-side
code.

This is a squashed combination of 138 commits from omapzoom:

Stagefright OMXCodec changes to enable TI Hardware Codecs

Descritpion:
These changes are ported from Froyo branch. The change details:
(1) Decoder table is updated with TI Ducati codec components
(2) OMX version is updated
(3) Component quirks are modified as per ducati codec requirements
(4) Codec configuration parameters are modified as per ducati codec
requirements

Change-Id: If845c3464281a1be053dbbff85c8db56b1163286
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Stagefright changes for video thumnail generation

Descritpion: These changes are ported from Froyo branch.
The change details:
(1) OMXCodec changes for quirks, bufferallocation
(2) Colorconverter changes to support strided buffer color conversion
from NV-12 packed to RGB
(3) stagefright metadata retriever changes for codec create with proper
flags and codec configuration changes required for Ducati codec

Change-Id: I252284d9e98653d9cccc46521e6391f1d439e90a
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Stagefright Changes to use externally allocated buffers

Description: These changes are ported from Froyi branch.
The change details:
(1) Video Renderer and OMXRenderer interface changes to pass buffers
from Renderer to Awesome player
(2) Awesoem player changes to set the buffers with the OMXCodec
and release the buffers once rendered
(3) OMXCodec changes to use the externally allocated buffers
while configuring the hardware codec.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 5: Cherry-picked on current tree.  No changes made.
Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I39e1c014eb52f9b0c2cb717671d0339889b09e07

Stagefright changes to support interlaced video formats

Description: These changes are ported from Froyo branch
Change details:
(1) Stagefrightmetadata retriever changes to check the video content
and configure teh OMXCodec with appropriate flags.
(2) OMX Codec changes to update the quirks and configure codec accordingly.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4 Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: Ia2e79d3883b2359ea416d5fcf509c4f3c38358e2

Stagefright changes for H263 decoders

Desrciption: These changes are ported from Froyo branch.
The change details:
H263 mime type and color format checks are added.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4 : Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: Iafac582a0b426503533fcd53f62d3ced91b89b15

OMXCodec changes for buffer alignment

Description: These changes are ported from Froyo branch
The change details:
A constant has been defined to make buffer size aligned on 32 bit boundary

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4 : Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I8e8850eaa907966fd9670a57a254c1328cfb1478

Non-PreAnnouncement mode for thumbnail generation

Description: These changes are ported from Froyo
Since tiler memory is limited we cannot have 2 instance of decoder 1 instance of encoder
and camera running in parallel. This is a requirement from 1080p camcorder perceptive.
To save tiler memory we are allocating only 2 actual full size buffers but remaining all
buffers as dummy. The dummy buffer will help us to move to idle state. Then we would provide
full allocate buffers only to ducati and then on receiving the Third EmptyThisBufferDone we
would send an EOS. This will flush out the Decoded first I frame buffer back to the component.
This is the frame from which we will make the thumbnail.

Here we have not voilated any OMX protocol but still able to save memory. This is called as
NON-PreAnnoucement mode where we dont give all the actual buffer to the OMX component before
Hand for mapping on the accelerator

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Icd9650f2aa51a2eb919b51962f4c9e61ca763fe5

OMXCodec changes for software codec

Descritpion: These changes are ported from Froyo
change details:
(1) property based checks are added for software codecc

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Patch Set 4: Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I3cd522ecaf69f8d46877fd89f10000550fbd8622

OMXCodec changes to add software decoders/encoders to the list

Description: The codecs table is updated with the Android software codecs.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 2: cherry-pick on current tree.  No changes made.
Verifications and approvals taken from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I4fdcf597fe087b54f6be10c0ad93dea0ce24bdce

OMX Renderer changres for on-the-fly resize support

Description: These changes are ported from Froyo.
Change details:
(1) Renderer interface is extended for resize
(2) Init Renderer is modified to call resize instead of destroy renderer,
if teh rendere is already created.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I519ba180cf652cf16ea7579e98c8a5278a16d790

Stagefright media extractor and parser changes

Description: These changes are ported from Froyo branch.
The change details:
(1) Extended MPEG4 extractor to support more format types
(2) Addition of cutom enums for openmax formats and errors

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on new tree. No changes made.
Taking verifications and approvals from previous patch
sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: If28b1605ea9e75f453adab7499095b5f69348af9

Stagefright and Surfaceflinger changes for S3D

Description: These changes are ported from Froyo
Change details:
(1) custom SEI parser is added
(2) Renderer creation is overloaded for s3d
(3) Awesome player has been modified to create the appropriate renderer
(4) Surface flinger is modified for appropriate overlay creation

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 7: Cherry-picking patch 4  on current head.  No changes made.
Taking verifications and approvals from patch set 4.  Just reuploading
to get description right.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I9e8824ac88279bacf6ad9e71dd2a94e6fefd9c73

StageFright Audio fixes

Description: These changes are ported from Froyo
Change details:
(1) Audio flush function is added
(2) quirks are updated for MP3 and AAC codecs
(3) mpeg4 extractor is updated for amr codecs

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on current tree.  No changes made.
Taking verifications and approvals from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic9f351b8b251aa29d36e1805014f27184c1dff22

Mediaplayer & AwesomePlayer changes for Video Cloning

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9754

Description# MediaPlayer interface and video Renderer interfaces have been
extended for enabling and disabling video cloning. Awesome receives the
Video mode state from mediaplayer and sets the renderer accordingly.

----------------------------------------------------------

Signed-off-by:<dnk.mohan@ti.com>

Patch Set 2: Cherry-picked on current tree.  No changes made.
Taking approvals and verifications from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I0eeec627987c16cf54e361cafb927809493629a1

Awesomeplayer changes for Video Cloning on HDMI after application suspend/resume

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,10447

Description# when Gallery app is suspended by pressing home button, MediaPlayer
gets suspended and underlying Renderer and overlay are destroyed. But the
Awesomeplayer is just reset. Hence the Videomode (normal or Clone) is left
to the last value set before the suspend.
Once the application is resumed, and tries to set the clone mode again,
it would be filtered at the AwesomePlayer level because of the cached value.
This is fixed by resetting the Video mode to normal while resetting the
Awesomeplayer.
----------------------------------------------------------

Signed-off-by:<dnk.mohan@ti.com>

Patch set 2:  Cherry-picked on current tree.  No changes made.
Taking verifications and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ie346c1a81b976ad56cfd7be675a26368556caf35

Stagefright: Updating meta data with profile,level,referenceframe data. Communicate to AVC component

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9467

- Added support to parse and save Video profile,level, scan-type,number of reference frames in meta data
- Communicate to ducati component
- Removed earlier isinterlaced() interface, and replaced with more updatemetadata() call in TIVideoConfigParser.cpp
----------------------------------------------------------

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 4: No changes made.  Cherry-pick on current tree.
Taking verification, approvals and build test from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I1bb89f27a19ac53461f0ed98a54b7adbee6c66a6

Flush the audio sink when resuming from a pause-->seek

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9462

1) Play an audio file
2) Pause playback
3) Seek to another position in the file
4) Resume playback
... some audio from the position before the seek is played before the audio at the new position is played.
This patch resolves the issue by flusing the audio sink before resuming the playback if there had been a seek
while the audio was paused
----------------------------------------------------------

Signed-off-by:<dnk.mohan@ti.com>

Patch set 3: Cherry-pick on current tree.  No changes made.
Taking verifications, approvals and build test from patch set
2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic2b135473f4400cbcc92b4f2906e482f07aa4c1f

Improve AV sync logic for accurate frame posting

Current logic:
1. On Play a 10msec defalt event is posted which has a callback onVideoEvent in awesomeplayer.cpp.
2. If we find a frame in renderer comming from Ducati then we check its time stamp against system / audio time stamp
3. There is a start delta which is always adjusted from the current time.
4. If the frame is late by 50 msec we drop it
5. If the frame is early more than 100 msec then we post a event after 10msec
6. if the frame is within 10 msec of current time then post it.
7. After a frame is posted we trigger a 10msec event to go to next frame

Flaws in current logic
1. we will never post it accurate; a 33 msec frame will get divided in three 10 msec windows and we will post it 3 mec early.
2. 100 msec check was wrong.
3. polling every 10 msec is increasing the MHZ
4. After displaying the frame we start a 10msec event which could have been 1 Msec to get more accurate posting results
5. Audio on OMAP4 increase the timestamp after 42 msec and we need accuracy of 1msec. So we will never have a precise posting

Modified logic
1. We check 10msec for early ness as per google original logic. Required for precise posting
2. For PPM optimization 2 things are done
1. Post the first frame event after 1 msec instead of 10 msec
2. Post the exact time future event for frame posting
e.g 33 msec we will have 1 msec and 32 msec 2 polls only reducing the ARM MHZ and also having precise posting of frame
3. Increase accuracy of audio by interpolating in between 2 audio frame increments. So polling in between 42 msec also provides
accurate results and keeps audio buffer sizes independent of AV sync logic
4. Added safety check so that if audio dies we dont keep playing video via interpolating logic.
5. A safety modulation logic is added so that if we seek we dont wait in the event for huge time.
This will cause hangs if we dont do this in seek case.
6. Added few instrumentation to know the exact delta between to postings
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 2: Failed rebase.

Patch set 3: Cherry-pick on current tree.  No changes made.
Taking verifications, and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic5651df3a8e657c123c670b11724e043218fb349

OMAP4:Stagefright player changes to use Codec recommended number of O/P buffers

Description: Currently there is no communication between OMX codec configuration
and the TIHardware renderer wrt the number of Overlay buffers to be used for
on the output port. In this patch, the Awesome player logic is enhanced to
query Codec for the recommended number of buffers for output port and
communicate the same down to TI Hardware Renderer. The codec recommended number
is buffered with the optimal buffer count to be maintained at the DSS driver.
With this patch the hardcoding for the output port buffer number is removed
and also the lower limit for the buffer count is removed in TIHardware Renderer.
this patch has to be merged along with 1.21-p5 ducati migration.

Validation: Tested AV playback from Android Gallery for different resolution cl$

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 2: Cherry-pick on current tree.  No changes made.
Taking verifications, approvals and build test from patch set
1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I7d858108e8768294ded1b2fc2c2887429f8968a7

OMAP3: create mCodecSpecificData without CodecConfig flag

This fixes a case that encoder returns the first buffer not
including CodecConfig. In case of OMX.TI.Video.encoder using
MPEG4 or H.264, the encoder does not return the CodecConfig
buffer but returns CodecConfig and the first encoded data
in one buffer without OMX_BUFFERFLAG_CODECCONFIG flag set.
Concerning the compatibility of Froyo and GB, this regards only
MPEG4Writer issue in GB.

Change-Id: Ie4d541fd6d3ae540eebbdebed0ef235ec0d557e7
Signed-off-by: keun-o.park <sahara@ti.com>

H264 encoder fixes for OMAP4

logic put in for OMAP3 h264 encoder is breaking OMAP4 h264 encoder.
Making change OMAP3 specific. Also fixing debug compilation error.

Signed-off-by: Dandawate Saket <dsaket@ti.com>

Patch Set 3: Simple Cherry-pick on tree.  Taking approvals,
verfications from patch set 2.  No changes made.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Iebfd4ca74b0c7c15c4bb504399653baa8a4e4a65

OMAP: Stagefright: Added rotation support to S3D Renderer.

OMX in Gingerbread need new HardwareAPI, createRendererWithRotation
to create rotated overlay for play video clips which have rotation info.
OMAP used old-fashion createRenderer to pass platform specific args,
such as isS3D, numOfOpBuffers but, no rotation degrees passed.

The function, createRendererWithRotation dynamically loaded
from libstagefrighthw.so only if it is defined. If not,
createRenderer will be loaded just like old times.

Change-Id: I440637aab1ba9c68fdb6eeb413095cf3814b5dad
Signed-off-by: Homin Lee <homin.lee@ti.com>

Gingerbread Camcorder : Generic Encoder chnages.

Description : These cahnges are generic to all the encoders. It sets the
               port configurations, I/p & O/p buffers count, Quirks for
              i/p * o/p ports, stride information & other generic ducati settings.

Signed Off By : Sreenidhi Koti <sreenidhi@ti.com>

Patch Set 4: Cherry-picking on current tree.  Merge conflict resolved.
Taking approvals and verifications from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I49d3af4f26e0e0948cf36e867d99c921ee106b2d

Gingerbread Camcorder : Support for H.264 Encoder

Description : Adds support for H.264 encoder.

Signed Off By : Sreenidhi Koti <Sreenidhi@ti.com>

Patch Set 5: Rebasing to break dependency chain.  Cherry-picked
on current tree.  No changes made.  Taking verifications and
approvals from patch set 4.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic2e811ac32ceadc2ae34dc7a9dc75c462df8a77c

Encoder-H264 : Support for B-Frames

This patch enables inclusion of B-Frames in H264 Encoded Video.

Signed-off-by : Kalpesh Patil <kalpeshpatil@ti.com>

Patch set 3: Simple cherry-pick to break dependency on non-existent
patch.  No changes made.  Taking approvals and verifications fom
patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I020e5d45febe2830e7a72536043267db051be2c0

Stagefright: OMAP4 output buffer count from codec - bug fix.

minimum no of buffers required on a port is communicated by codec via video.portdef.nBufferCountMin
actual no. of buffers allocated on a port  is communicated to codec via def.nBufferCountActual parameter.

Today def.nBufferCountActual is used to set buffer count which is not intended and causing high buffer count usage

Signed-off-by: Devaraj Rangasamy <dev@ti.com>

Patch Set 2:  Simple cherry-pick on current tree.  No changes made.
Taking build test, verifications and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ib9f57aa981b86408aaf7612f80b3540587d57e7a

Store Stride in the meta data.

Stride is required by flash to perform color conversion.

Note# these changes are ported from Froyo
http://review.omapzoom.org/#change,10713

Signed-off-by: Anu Sundararajan <sanuradha@ti.com>

Patch Set 2:  Cherry-pick on current tree.  No changes made.
Taking verifications, approvals and build test from patch set
1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I3404dd2f3687f59618d50b7fc297c9d48a6301cb

OMXCodec: Initialize quirk to kRequiresAllocateBufferOnOutputPorts

If the quirk is set to kRequiresAllocateBufferOnOutputPorts by the
OMXCodec Client, then AllocateBuffer is called on the output buffer
else UseBuffer is called. UseBuffer can be called only for Overlay
buffers. Ideally speaking, one should not expect the client to know
these details. They must be handled internally.

In the case of flash playback, it is expected to call
OMXCodec::Create() with the flag kPreferAllocateBufferOnOutputPorts.
This flag is a TI specific flag and hence flash is unaware of it.
Furthermore, it cannot be hardcoded in flash since the enum value
has been changing too.

Patch Set 3: Resolved OMAP3 build issues by making it OMAP4 specific.

Signed-off-by: Anu Sundararajan <sanuradha@ti.com>

Patch Set 4:  Simple cherry-pick on current tree.  No changes made.
Taking build test, approvals and verifications from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I8ad9697cbaf25d04b0d5e3e394fd2db66b78fe59

Stagefright: Making kRequiresAllocateBufferOnOutputPorts as default quirk breaks NPA thumbnail mode

Changeset1:
  - Making kRequiresAllocateBufferOnOutputPorts as default quirk breaks NPA thumbnail mode
    Clear it for NPA thumbnail mode

  - Break was introduced by http://review.omapzoom.org/11427

Change-Id: I14ba6d98398903a436b306e1e5490f6d83341719
Signed-off-by: Devaraj Rangasamy <dev@ti.com>

OMXCodec changes to handle overlay decided buffer count

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9211
Description: Currently, the number of buffers required on code output port are
calculated in OMXcodec as well as in TIHardwareRenderer.
And OMXCodec assumes that those many buffers are in deed allocated by overlay.
But in some scenarios it it so possible that, Overlay might get fewer number
of buffers than requested by OMXCodec. In that scenario there will be a
segmentation fault in the system. In order to handle this scenario, OMX codec
is enhanced to reconfigure the codec when it receives the buffers from the
Hardware Renderer (through AwesomePlayer) for the first time.
----------------------------------------------------------

Signed-off-by:<dnk.mohan@ti.com>

Patch Set 3: Cherry-pick on current tree.  No changes made.  Taking
approvals and verifications from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ie1642d25eb8f520cb796526882969cb70e751acd

OMAP4: Re-enable Vorbis decoder

MIMETYPE of Vorbis audio decoder contents is missing after
OMAP4 integration, resulting in no OGG sound

Patch Set 2:  No changes made.  Simple cherry-pick on top of
current tree.  Taking verifications and approvals from patch
set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I24a85288ad124c345ef0a9035d18e0d247fc2af3

Stagefright: Added support for 2 new codecs - VP6 and VP7

Description# Modified OMXCodec table to include ducati VP6 and VP7 codecs.
updated decoder caps for the same. And updated ducati specific checks for
VP6 & VP7 as well.

Note# These changes are ported from Froyo

Patch Set 2: Rebased against latest.

Change-Id: I6bd46ed45c862e21e80e2b11166b846881ba4406
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Signed-off-by: Anu Sundararajan <sanuradha@ti.com>

Stagefright: Enable support for dynamic port -reconfiguration while using Ducati IVAHD codecs

Patchset1:
  - When codec detects change is width,height of the stream, it raises port reconfig event, port is disabled and enabled.
  - For port  -reconfiguration during AVPlaybakc usecase, Since new set of overlay buffers are required before re  -enabling port, defer port enable for ducati playback usecase till overlay buffers are available.
  - ResizeRenderer() should be aware of new output buffer count for new resolution
  - For port  -reconfiguration during thumbnail usecase or stagefright   -t tests, retry will happen in StagefrightMetaDataretriever, while output port will disable and reenable itself with allocated buffers.
  - Limitation: NPA mode for thumbnail is not working for now and disabled. will be enabled incrementally

Patchset2:
  - Rebased to latest codebase

Signed-off-by: Devaraj Rangasamy <dev@ti.com>

Patch Set 3: Cherry picked on current tree.  No changes made.  Taking
approvals, build test and verifications from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I1eabf4fb9d060dc5126b443cbe77f687687ec7d9

OMXRenderer changes to propagate display W&H on resizing

Description# OMXRenderer is modified to propagate the display
W&H along with the decoded buffer W&H while resizing the
rendererer. This is required to update the crop window with
Overlay.

Awesomeplayer is modified to query the Video width and height
and provide the same for resize Rendererer call.

DRT#OMAPS00236082 - Multiple robustness test clips are playing with noise
in the right side of screen due to incorrect port reconfig handling
Note#This is one of the multiple patches for this DR
this patch is dependent on
http://review.omapzoom.org/#change,12705

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 3: Simple cherry-pick on current head. Taking approvals,
verification and build test from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Iceadb97202750b08dd45f8749a5337d5c69f0dc5

Surfaceflinger changes for dynamic display change

Description: These changes are ported from Froyo
change details:
(1) custom omap mm library has been added
(2) Surface class is extended for display ID settings and introduced omapmm
lib as a friend class
(3) Layer base and buffer class changes for display setting to the Overlay

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 5: rebased again.  Merge conflicts fixed.
Patch Set 6: Patch Set 5 with a comma in include/surfaceflinger/ISurface.h.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: If13257af633958fab57a63a504b17d17c27d2537

SurfaceFlinger changes for Overlay cloning

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9708

Description# ISurface interface is extended for dynamic overlay cloning.
This includes ISurface binder extension and layer buffer implemetation
to call overlay data context for requesting overlay cloning.
The same interface is used for enabling/disabling the overlay cloning.
Hence based on whether this is enable or disable, the ISurface interface
handles duping the fd for the cloned video device.

----------------------------------------------------------
Signed-off-by:<dnk.mohan@ti.com>

Patch Set 2: No change made.  Simple cherry-pick on current tree.
Taking verfications and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ie1df963238ffa83181b36fd1cb92b9aa5ce020ce

Changes made to OMXCodec.h so that a derived class can be created.

Minor changes made to the class definition so that we can create a TIOMXCodec that is derived from OMXCodec.
In future, all changes to OMXCodec should be made in TIOMXCodec, instead.
AwesomePlayer also needs to be modified to use TIOMXCodec instead of OMXCodec.

This is necessary in order to maintain compatibility for flash playback.
Note# these changes are ported from Froyo
http://review.omapzoom.org/#change,9014

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 2: Simple cherry-pick.  No changes made.  Taking
approvals, build test and verifications from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Id687b5b2e84c71f1aab71276d5c0ae16770431c2

Stagefright: Re-enable NPA mode for thumbnail generation, which was disabled for port reconfiguration changes

Changeset1:
 - Our Stagefright NPA statemachine has to be reset when PortReconfig is triggered,
   so as to go ahead with post port-config sequence

 - For 1D output buffer usecases, port config should result in nStride update as nFrameWidth will be new.
   No chagne for 2D output buffers, since constant 4K stride is used

Changeset2:

 - Rebased

Signed-off-by: Devaraj Rangasamy <dev@ti.com>

Patch Set 3:  Breaking dependency on merge commit.  No changes made.
Taking approvals and verifications from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic421140a892384b8c30a9e59e2d5076b1bd8fa65

Gingerbread : Including TI Index header files & removing duplicate codes

Description : Removing duplicate codes by including TI index header files.

Signed Off By : Sreenidhi Koti <sreenidhi@ti.com>

Patch Set 5:  Cherry-picking on current tree to break the dependency on
patch 9556.  Taking approvals and verification from patch set 4.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I9063c273426fb1987c9c20d04af6f10633140b20

FM Rx: Added FM framework support

This patch is rework of patch 6235 (cd38325421b73ae5693b1f9991aeeb5b982154c8) on p-froyo for FM Rx
changes. The audio flinger directory is changed in gingerbread. Resubmitting the patch for FM Rx in
gingerbread. All the changes are in OMAP_ENHANCMENT flag

Description: FM Support: Added the FM support in the framework for enabling FM.

Change-Id: I1ff2f6484c673522f83659d9696aba6a2060a798

Defined the DEVICE_OUT_FM_TRANSMIT for FM Tx device in Android Framework

cherry picked from p-froyo commit-id b820e1009d4c619c254ef6cfaa58cf48182b4e3f

Signed-off-by: Shitiz Kumar <shitiz_kumar@ti.com>

Patch Set 2:  Cherry pick onto current head.  No changes made.
Taking verification and approvals from previous patch set.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: If8c05732954fd7b2c7ca908504a9e27820b115c5

add support for Low Power and DMIC

    AudioService registers for intents from applications
    that notify of mic selections, and changes in power mode.

    For now, mic choice will be determined by system property only.

    For changes in power mode, AudioService will set the connection
    state of a new DEVICE_OUT_LOW_POWER and trigger policy manager to
    route to the low power hw device.

Signed-off-by: Chris Kelly <c-kelly@ti.com>

Patch Set 2: Removed whitespace error.  No significant changes made.
Taking approvals and verifications from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I9085217d76d5e897c855df31d397a604649ef04c

AudioSystem: voice call record: new channel CHANNEL_IN_VOICE_UPLINK_DNLINK

Voice call record is started by selecting inputsource
AUDIO_SOURCE_VOICE_UPLINK or AUDIO_SOURCE_VOICE_DOWNLINK
or AUDIO_SOURCE_VOICE_CALL.
For inputsource AUDIO_SOURCE_VOICE_UPLINK and
AUDIO_SOURCE_VOICE_DOWNLINK, there's only 1 dedicated input channel
that permits to start record in mono.
But for inputsource AUDIO_SOURCE_VOICE_CALL, there's no dedicated
channel so the channel CHANNEL_IN_VOICE_UPLINK and
CHANNEL_IN_VOICE_DNLINK are enable.
Therefore the record is done in stereo.
To avoid that and be inline with a voice call record uplink only
or downlink only a new input channels is created.

Change-Id: I6f1d383e185b51d4798db8e62f9310a52ad8da7c

Add a java OMAP_ENHANCEMENT property definition

Cherry picked from 3f812d8daf3ffa685104083abeb7fcb30056baf1

Change-Id: I439fc98cbb38e07044d568444ed9a729a0172e81

OMXCodec changes to overload constructor for OMXNode Id

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,10897
Description# OMXCodec create function is overloaded to provide OMXNode Id
handle back. The node Id is used by the Awesomeplayer for configuring the
codec directly.
This patch is only addition of the overloaded method, but the method is
not being used at this point.
----------------------------------------------------------
Patchset2: Fixed build error for OMAP3

Change-Id: I52fb78486048f66e00608e08d31bd20b32f2c178
Signed-off-by:<dnk.mohan@ti.com>

GingerBread Camcorder : Support for padded width & padded height.

Adds support for padded width & padded height in Stagefright AV-Record path.

Patchset-3 makes correction in width & height used for SetParameter for
OMX_TI_IndexParam2DBufferAllocDimension.

Signed Off By : Sreenidhi Koti <sreenidhi@ti.com>

Change-Id: I60aa6a5caf01218d6650eea2f090427a16b46d02

Stagefright fix: Low resolution clips crash with ducati codec

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9651

- MediaBuffer mSize should used video padded height, rather than original video height,
since output buffer size will have padded width and height.

Break should've introduced when Android video proxy is updated to remove 2D buffer support.
----------------------------------------------------------

Signed-off-by:<dnk.mohan@ti.com>

Patch Set 2: Cherry-picked on current head, no changes made.
Taking verifications, approvals and build test from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I142b622a7c4455e7cfe431847001a458a8875599

OMXCodec fix for buffer size calculation.

Description# When the video source meta data is maintained
separately for video frame w&h and buffer w&h, the buffer size should be
calculated from the padded height instead of the Video height.
This was missed out earlier, this patch corrects the buffer size calculation.

Change-Id: Idd46b71e050c2c3759b92330aa91aea52878591b
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Stagefright: Thumbnail corruption fix on port reconfig

Patchset1:
 - On port reconfig, thumbnail driver or any other OMXCodec user should be aware of updated WxH
   MediaTrack metadata will have new WxH
   OMXCodec MetaData will have padded WxH (this is by default)

 - Whitespace changes (remove tabs)

Signed-off-by: Devaraj Rangasamy <dev@ti.com>

Patch Set 2:  Simple cherry-pick on current tree.  No changes made.
Taking approvals and verifications from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ibeb7935307c49492e482dc74d779a69300e4b620

Stagefright changes to maintain buffer padded W&H along with Video W&H

Description# Stagefright OMXCodec and AwesomePlayer are modified to
store and use the padded width and height for the output buffers.
This is required to handle port reconfiguration scenarios where in,
both video dimensions and buffer dimensions are required. Earlier the OMXCodec
metadata was always holding the padded width and height, hence there was
no way to communicate the video dimensions to Awesomeplayer.

DRT#OMAPS00236082 - Multiple robustness test clips are playing with noise
in the right side of screen due to incorrect port reconfig handling
Note#This is one of the multiple patches for this DR

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 3:  Simple cherry-pick on current head.  Taking approvals,
verfication and build test from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I441c95dece8b126794f749759d6b6fc651f27094

Moving Input buffer of video decoder to usebuffer call

Currently we are using allocate buffer call for input buffer.
These buffers are 1D tiler buffers and allocated by DOMX.
We see improvement in memcopy if we ask omx il to allocate buffer
and pass it to the component. THis improvement in copy time is
due to cache attributes. So we have moved to use buffer than
allocate buffer. This was also recomended by PSI team

Defect ID: OMAPS00229223

Change-Id: Ib2d355417e479fe2be76c3d5ce5e127158fcf482
Signed-off-by: Dandawate Saket <dsaket@ti.com>

Resolved VP6/7 playback issues

New extended OMX parameters must be set for VP6/7
depending on the type of stream.

Note# these changes are ported from Froyo
http://review.omapzoom.org/#change,9653

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 2: Cherry-pick on current tree.  No changes made.
Taking verifications, and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Iee8d579bfc4dd7e93cb08275a89e2514aef05e32

Add support for ASF parser in Stagefright

This patch adds the changes needed to support the ASF parser which is needed for playing
WMV and WMA clips.  This patch does not contain the parser itself but it makes the parser
runtime-discoverable.

Change-Id: I72bad81bbdecc5293b0528b593d9cd3df4f65815

VideoView changes to handle Dynamic display changes

Description: This patch includes changes in the VideoView widget to
load the custom java/jni, and send dynamic display change events to the JNI.

Note# these changes are ported from Froyo branch

Change-Id: I95f9ca064375985501cebf1ef228a1ed4e18d36f
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

VideoView changes to enable Video cloning on HDTV and LCD

Description# Video view is modified to set the mediaplayer with the Omapmmlib.
This mediaplyer instance is used by the Omapmmjni service to enable
video cloning on media player.

Validation# tested aV playback on LCD and HDMI

Change-Id: Ia8fdc3ebb2c002fe07ea9321b831d63a9cc4f862
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

OmapMMLibrary changes for Video Cloning The changes are for porting the below patch from Froyo to Gingerbread ---------------------------------------------------------- http://review.omapzoom.org/#change,9755

Description#OmapMMlibrary is extended to talk to mediaplayer for
video cloning. Video view is modified to set the mediaplyer instance object
with the omapmm custom library.
----------------------------------------------------------
Patchset2: Removed changes in videoview.java as it will be handled in another patch
to avoid build issues.

Change-Id: Iaa5cfeba74e3884397a4f301b6d5380b8b2f85a7
Signed-off-by:<dnk.mohan@ti.com>

stagefright: Pass offset value of the frame data from camera source to omx codec

When VNF is enabled the data received from camera source provides an offset
value with each frame that has to be passed to the omx codec (ducati) for
proper encoding. In the absence of this there were artifacts seen in the
resulting output. This patch addresses this issue.

Solves DR#OMAPS00233255

Verified sanity on AV record/playback.

Signed-off-by:<dnk.mohan@ti.com>

Patch Set 3:  Addressed the formatting issues raised by Dan.
Taking approvals and verifications from patch set 2 since no
code was fundamentally changed.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I2081c1038195671843d83977d8940af1914731f1

Framebuffer: Support variable number of framebuffers in the UI

This change defines a macro NUM_FRAME_BUFFERS to set
the desired number of framebuffers to be used by the UI,
instead of hard-coding 2 framebuffers.

Aditional logic was added to handle the initialization and destruction
of NUM_FRAME_BUFFERS buffers.

Ported from FroYo

Change-Id: I86c707d6deaae61ef72e5e48ae91437b2472977a
Signed-off-by: Rodrigo Obregon <robregon@ti.com>

Native window support for any FB.

This patch allows clients of the class FrameBufferNativeWindow
to be able to create a native window surface on any display.

Change-Id: I8902858be85b83b287b8d9944bc80c82e7c34e1f
Signed-off-by: Rodrigo Obregon <robregon@ti.com>

OverlayRenderer: A new class for accessing Overlay

Since only the mediaserver process has the necessary permissions
to create a surface and to create an overlay, we need this new class
for the flash plugin to make use of overlay.
Note# these changes are ported from Froyo
http://review.omapzoom.org/#change,9245

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 2: Cherry-pick on current tree.  No changes made.
Taking verifications, and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic482acffd3148d7b4b189646f4741cfe85a430a9

IOMX: implement getBuffer() call for IOMX interface, so as exteral application use own player driver

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,10692
if External applicaiton creates a player driver(awesomeplayer), then H/W renderer is
created by MediaServer if the AwesomePlayer, which is created by external-application
wants to send buffers to the H/W Renderer, it have to send by Binder calls.
This patch implements getBuffer Binder interface between H/W Renderer of MediaServer
and AwesomePlayer of external application.
----------------------------------------------------------

Signed-off-by:<dnk.mohan@ti.com>

Patch set 2: Cherry-pick on current tree.  No changes made.
Taking verifications, approvals and build test from patch set
1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I6cddb8f06a8bbf857763839ed5de698c303c9a6a

OMAP4: Enable Stride and Offset Support in Camera Framework

Modify camera and stagefright framework for taking
stide and offset from timestamp callback

Change-Id: I19308cda849bfad3a03dbe7fe070c38ab5bdc5d4

Conflicts:

	services/camera/libcameraservice/CameraService.h

OMAP3: SF: Fix the misuse of mLastVideoBuffer in AwesomePlayer

mLastVideoBuffer is not used with OMAP_ENHANCEMENT flag. And,
current code causes a segmentation fault when it tries to access
mLastVideoBuffer which is not initialized at constructor.
This fixes the segmentation fault in suspend function.

Because there's no code for OMAP4, 'if(0) {' routine for OMAP4
was still left unchanged.

Change-Id: Ie2a8abaf3f36a62235be4331956a74737c8aa896
Signed-off-by: keun-o.park <sahara@ti.com>

OmapmmLib changes to fix native surface field

Description# surface class mSurface field id replaced with mNativeSurface.

patchset2: rebased to the latest codebase.

Change-Id: I7bdc8148ea8bf58ce73a62cd6d68e0f44c6cc84e
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

OMXCodec fix for NPA mode thumbnail scenario

Description# The mNumberOfNPABuffersSent state variable
update is corrected in fillbufferdone callback.
Earlier we were decrementing the state variable in
FillbufferDone callback unconditionally.During port
reconfiguration scenarios we were resetting this variable
to "0" hence the further decrement in FillBufferDone callback
was wrapping around this unsigned state variable to large value.
This was resulting in no buffer sending to Ducati for thumbnail
generation, hence thumbnail generator was hanging forever.

This is fixed by decrementing the mNumberOfNPABuffersSent state
memeber only if it non-zero positive number.

DRT# OMAPS00236210 - No thumbnails generated for the clips which result
in port reconfiguration

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 2: Simple cherry-pick on current head. Taking approvals,
verfication and build test from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ibaaca788497583ab7d0fadef5cc491c72dfb0486

OMXCodec changes for tearing effect

Description# In the OMXCodec buffer info, a new field has been added to track
the buffers which are with Player. This means the buffer could be in AV sync
logic, or already with DSS for rendering in case of video buffers, or with
Audio HAL incase of Audio buffers. Earlier these buffers are given back
to codec for filling irrespective of whether they are with sink or free.
This is fixed by adding additional state for the buffer to track the
life cycle of the buffer with the sink.

Validation# tested AV playback and AV record.
DRT#OMAPS00234704 - Tearing video frame on display when fastford/rewind
during the video playback

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 2:  Simple cherry-pick on current tree.  No changes made.
Taking approvals, verification and build test from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I1bcddddfeaf79c624f304b63f0b342625a4d6e33

OMAP4: S3D: OMX component configurations to handle SEI messages for video playback

       Description: Reads Codec buffer metadata to reconfigure S3D display driver

                    - Parse output buffer for SEI MetaData
                    - Read metadata and configure S3D display driver
                      upon framelayout changes sent by codec

       Note: Patch ported from Froyo
       Dependencies: Patches 13385

Change-Id: I1a1afc1159248f98fc199c0aa288366a592f7e89
Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

Gingerbread Camcorder : Fix for color distortion in Recorded Clip

Encoder needs a NULL buffer pointer to be passed to OMX_UseBuffer() fucntion.
Whereas Decoder needs a valid buffer pointer for the same.
This patch adds an overloaded function definition for useBuffer() with extra argument 'size'.
For Encoders, this size is passed to OMX_UseBuffer() along with NULL buffer pointer.
For Decoders, this size is ignored.
With this patch, decision is taken which argument to pass based on if component is Encoder or Decoder.

Signed-off-by : Kalpesh Patil <kalpeshpatil@ti.com>

Patch Set 4: Simple cherry-pick on current tree.  No changes made.
Taking verifications and approvals from patch set 3.
Change-Id: I176881dd632af2f61e9ed6ade02f6d50e1edbc94
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Patch Set 5: fixed compilation issue with OMAP3
changed #ifdef to be omap4 specific in include/media/IOMX.h

OMAP4: Include OMX_TI_IVCommon.h header file to support definition of color format (PackedSemiPlanar_Sequential_TopBottom)

        -- Remove the definiton from Stagefright includes files as
        it is a TI custom index.

        Note: Patch ported from Froyo.
	Dependencies:
              GITS    omx    (http://review.omapzoom.org/#change,10685)
                      omap3  (http://review.omapzoom.org/#change,13389)

Change-Id: Ie45ac17d985a5008c631e5c5d8b49e3a849f5dea
Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

Avoid deadlock in OMX::freeNode

By making sure OMXCodecObserver does not hold the
last reference of OMXCodec object

Mirroring change in OMXCodecObserver from mirror update. Mutex
is removed from on_message and moved to onMessage function in
OMXCodecObserver. Fixes race condition we see when stopping
video record.

See 6328185b6cc632f85ff640f6e854ab33815ae97f from gingerbread mirror

Change-Id: If5f4c92f06eb56060659547db39341b428da2b9f

Code cleanup to fix some issues introduced in the ASF parser patch

Fixed following issues:
- Removed complete path from a #include
- Removed leftover debug messages
- Fixed indentation
- Fixed whitespace issues

Change-Id: Ia509d62cd1b93509cf6708eebcd44ae0b0808b50

Changes to support repeated PAUSE_RESUME Scenario.

Consider the following scenario:
1. Buffer arrives early, means in function onVideoEvent mVideoBuffer is not set to NULL
2. Pause
3. Resume, play_l is called successfully at this point
4. In function onVideoEvent, mFirstVideoBuffer is not made NULL as mVideoBuffer is not NULL (see point 1)
5. Again Pause
6. Then Resume
7. play_l is called with mFirstVideoBuffer non-NULL
8. play_l fail in CHECK(mFirstVideoBuffer == NULL)

This patch corrects this issue by releasing mFirstVideoBuffer, if it has not been released already in onVideoEvent

Change-Id: Ie9de7c647936aee3c16bf2ab0ea4cb7bae3cae04

Stagefright: Awesome player and OMXCodec changes to fix some types of port reconfig

Port reconfig is supported as of now. But it does not support port reconfig
during playback (after playing some frames).
This patch adds changes to appropriately flush the buffers towards OMX component
and the renderer.Also it sends proper free buffer requests to OMX component to
enable proper state transitions in OMX component.

Verified with available port reconfig clips.

Patchset2:
For clips having Port reconfig at the beginning sometimes there was a race
condition on causing failure to start playback. This is addressed by adding a
delay in setbuffers before flushing the buffers with freeBuffersOnPort().

Signed-off-by:<dnk.mohan@ti.com>

Patch Set 3:  Simple cherry-pick on current tree; no changes made.
Taking approvals and verification from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I5ef8feb46812f1c34e0398d208cd0336d1bdcfe2

AwesomePlayer changes to handle the render buffer failure scenario

Description# Currently Awesome player local data structures are updated with
the buffers with renderer after the render call returns. This would leave out
a scenario where, the render call fails to successfully queue the buffer
with the DSS. In this scenario the buffer can't be reclaimed as it is not
registered with the Awesomeplayer.
This is fixed by updating the bufferswithrenderer structure before invoking
the render method.

Validation# AV playback suspend/resume on LCD and HDTV
DRT#OMAPS00234816 - Gallery app stop reponding after pressing END CALL key
while playing a video on HDMI
DRT#OMAPS00234810 - PT: PPM: AV Playback on HDMI. Video is not rendered back
to HDMI after suspend/resume; instead is played distorted in the LCD

Change-Id: Ib6ce15c6f87c81eeb67b4eb6316f8801cdddc816
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

OMAP3: set static buffer count for video output

Due to VRFB buffer limitation, it is needed to limit the buffer count
of output port for OMAP3. This fixes that memcpy is used for video
output.

Signed-off-by: keun-o.park <sahara@ti.com>

Patch set 6: Simple cherry-pick on current tree; no changes made.
Taking approvals, build test and verifications from patch set 5.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I254032d9235e11bc5203560f3de1e8c728f84960

Modified Buffer Allocation logic for Video Decoders

Current logic:

For all video decoder usecases (thumbnail, gallery playback, stagefright tests,
flash playback, etc), call OMX_UseBuffer for output port.

For Non-Overlay usecases, the output buffers are allocated by MemoryDealer.
For Overlay usecases, the output buffers are allocated by Overlay.

This ensures that there is no memcpy even when OMXCodec(browser process) and
OMXNodeInstance(mediaserver process) live in two different process contexts.

Patch Set 2&3: Rebased patch on current tree. Fixed merge conflict.

Change-Id: I94eecfa337f115d268ffd26ad95e93ab388529d5
Signed-off-by: Anu Sundararajan <sanuradha@ti.com>

OMAP3: lib StageFright crashes on end of decoding WMA

WMA Decoder sends stopped signal twice at the end of decoding.
The second signal will cause Stagefright to crash due to invalid
thread state.

Signed-off-by: Steve Schefter <sschefter@ti.com>

Patch Set 3:  Simple cherry-pick on current tree.  No changes made.
Taking approvals, verifications and build test from previous patch
sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I0258d3d7124479bc00f0288604a4c5c6966e26f5

Surfaceflinger changes for overlay integration

Description: These changes are ported from Froyo
Change Details:
(1) LayerBuffer class is modified to route Layer calls to Overlay library

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on current head of tree.  No changes
made.  Broke the dependency chain.
Taking verifications and approvals from previous patch sets.

Change-Id: I62bb72f36d2d8f9be34c129337527f7f4742ed64

SurfaceFlinger changes to decide when to enable the color key

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,9443
Description: Since color key and per-pixel alpha need to be enabled exclusively
there should be a mechanism in surface flinger to decide when to enable
color key and when to disable.
a new method has been added to the surface flinger to query the graphic plane
pixel format and then enabl/disable color key accordingly.
----------------------------------------------------------

Change-Id: Id7b08c9bcb1187e9eb90fc31f237b3b66c033f4b
Signed-off-by:<dnk.mohan@ti.com>

Moving Input buffer of video decoder to usebuffer call

Currently we are using allocate buffer call for input buffer.
These buffers are 1D tiler buffers and allocated by DOMX.
We see improvement in memcopy if we ask omx il to allocate buffer
and pass it to the component. THis improvement in copy time is
due to cache attributes. So we have moved to use buffer than
allocate buffer. This was also recomended by PSI team

Defect ID: OMAPS00229223

Change-Id: I8518c1adf2389028417ee2f041f2aa8b92bb395f
Signed-off-by: Dandawate Saket <dsaket@ti.com>

Both OUT and IN buffers should be 128byte aligned according to DSPBridge requirement.

When decoding H264 video via Flash10 Player, OUTPUT buffers are allocated by Stagefright *OMXCodec.cpp), but they have not been 128byte aligned. And it causes the DSPProcessor MAP failure.
This patch applies 128byte alignment for OUTPUT buffer before allocating the memory by Stagefright.
For INPUT buffers, 128byte aligned size is set by OMX before, so we don't need to re-aligned it by Stagefright again.
For the Gallery usecase, OUTPUT buffers are allocated via Overlay, so we don't need to make a alignment here.

Patch Set 2:  Simple cherry-pick on current tree.  No changes made.  Taking
approvals and verifications from previous patch set.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ib54eae1fe173f4393643f91e9dd498cfb2a4584d

Reduce memcpy in mpeg4extractor for H264

Currently the file content is read into a source buffer and then
parsered for NAL unit size. Then the start code and nal unit is
dumped in destination buffer provided by application.

The code is optimized to put the data from file directly into
application buffer.

Defect ID: OMAPS00229223

Change-Id: Ie6411145fcd5bc1cac4d0d76efee2cb3c133185d
Signed-off-by: Dandawate Saket <dsaket@ti.com>

MPEG4 Extractor memcpy logic correction

Description# Currently the memcpy logic inside MPEG4Extractor
works fine for mNALLengthSize = 4, but for the clips which have
different mNALLengthSize the logic results in segmentation fault.
The memcpy logic is corrected in this patch.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 2:  No changes made.  Taking verifications and approvals
from previous patch set.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I95355367e17df9eeb172f7716ab048880af9af85

OMAP4::S3D: Fix S3D playback of recorded videos

	Note: -Add support for multiple SEI types per NAL Unit
	to support recorded videos.

	      -Add OMAP4 flag around SEINALLength initialization

	Patch set 3 - fix SEINALLenght init for GB.

Change-Id: I2f9a8561792d08a8b17e17566b8dee56051bc260

Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

libstagefright: Confine port reconfiguration related changes to Ducati video decoders

The below patches
http://review.omapzoom.org/#change,11472
http://review.omapzoom.org/#change,11485

have port reconfiguration related changes that are relevant to
Ducati video decoders only. For other omx decoders(eg:audio)they are not
applicable and will cause issues at start of decoding.
This patch adds additional checks for this purpose.

Verified AV playback and Thumbnail generation.

Signed-off-by:<dnk.mohan@ti.com>

Patch Set 2:  Simple cherry-pick, no changes made.  Taking
approvals and verifications from patch set 1.  Taking build
test from there too.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I2280dbb2086022fb508e21c214487f111dbd6bdb

Setting mOverlay to 0 after destroying it

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,4536
Setting mOverlay to 0 after destroying it

This was a fix made on HTC Codebase to resolve some Seg faults.
Hence migrating it from Donut to eclair to froyo.
----------------------------------------------------------

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch set 2: Cherry-pick on current tree.  No changes made.
Taking verifications, approvals and build test from patch set
1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I692a831441016a2a7054bfcd14928a84a59648d9

LayerBuffer fix for Dynamic Display ID change

Description# HDMI Hotplug support is added by modifying the Layer dpy field
from the omapmmLib. This dpy is modified inside the Layer Source on every
display Change event. In this model, there is corner case possible where in
We initiate the suspend/resume, but abort it immediately. This would trigger
HDMI detach in the kernel and hence the detach event is propagated to LayerB
But by this time if the OverlaySource is already destroyed keeping the Layer
Buffer alive, we miss this Layer dpy update. Hence on immediate resume,
The overlay source would see HDMI as the current dpy and configures overlay
for the same even though HDMI is not yet attached in the kernel.
This would result in Overlay configuration failure and hence no Video on LCD
or TV.
This is fixed by initializing the Layer dpy to 0 while constructing the
Overlay source.

DRT# OMAPS00235635 - PT: HDMI AV Playback: When resuming system, before
unlocking the screen, the notification bar shows the clip playing.
DRT# OMAPS00235626 - HDMI AV Playback suspend/resume: Gallery hang

Change-Id: I73f66dd8049849748cc86cc1ad28e9b68294c1a7
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

OMAP3: SF: fix build error

This fixes 'frameworks/base/media/libstagefright/AwesomePlayer.cpp:
1368: error: 'MEDIA_MIMETYPE_AUDIO_WMA' was not declared in this
scope' in OMAP3

Change-Id: I13325b54b75ff314a567ef4ab8239322630996ff
Signed-off-by: keun-o.park <sahara@ti.com>

libui: Ensures there isn't an uninitialised function pointer

This patch fix the boot up issue in gingerbread with DDK 1.7.17.4958
for using cancelbuffer.

Change-Id: I21336878b39efa0b804ce232a23eebe09e3cd5c0
Signed-off-by: Eric Luong <x0119002@ti.com>

Camera Framework: Adds support for burst messages

                        - Burst, Exposure and Temporal
                          bracketing are being started and run
                          with just one call to takePicture. The
                          existing mechanism in CameraService
                          prevents this by explicitly reseting and
                          checking the compressed message
                          type during each dataCallback. The
                          new burst message type on the other
                          hand will continue processing burst
                          frames until the sequence completes.

Signed-off-by: Emilian Peev <epeev@mm-sol.com>

Patch Set 6: Simple cherry-pick on current tree.  No changes made.
Taking verifications and approvals.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: Ib9bfdeae1e4121b5d09f09001224acd9df3b5b40

OMAP4: Enable Camera on Gingerbread

Modify CameraService to select correct overlay format

Change-Id: I4c90cb9161db0d237649f706430e397a4918a1d3

Enable S3D preview in camera framework

Porting over changes from Froyo to enable
S3D preview.

Change-Id: I47a5ab32072a5b118c8ca8ea239e92aa857e655d

Gingerbread Camcorder : Support for H.263 Encoder

Description : Adds support for H.263 encoder.

Signed Off By : Sreenidhi Koti <Sreenidhi@ti.com>

Patch Set 4: Cherry-picked on current tree.  No changes made.
Taking verification and approvals from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: Ib0ac27fa493b567279cd4a28b121183ca56a9006

OMAP4: S3D: Add SEI Video Encoding configuration support in Stagefrigth

	Description:  Get Camcorder encoder settings and configure OMX component
		      to incorporate SEI messages.

	Patch Set 7: Set preset values to userdefined in case of S3D

Change-Id: I2982cb71fc8dfdfef33c3b60a97a1c044e083188
Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

Removing initial seekTo(0) when playing back camera shutter sound.

This fixes DR OMAPS00236070.  After boot, with headset plugged in,
when doing an image capture, the shutter sound would play twice due to
an unnecessary seek from the camera service. The seek in this case is
happening before the AudioPlayer is created, and thus, it gets treated as
a deferred seek, which results in the AudioPlayer not being able to do
a simple end of stream call.

Signed-off-by: Ricky Bhatia <a0866433@ti.com>

Change-Id: I7938657c3ceecc01e09ea14d4e42493e190b8146

OMAP3: Handle NULL pointer exception in RawCallback

Change-Id: Ic3a4ca6d2dd58b864be60d183af16bd9562680bb
Signed-off-by: Julian Shandorov <jshandorov@mm-sol.com>

Gingerbread Camcorder : Setting the correct colour format for recording

Descrition : Using YUV420PackedSemiPlanar color format for recording use-cases.

Signed Off By : Sreenidhi Koti <Sreenidhi@ti.com>

Change-Id: Iea7316ca75cf52d3e06c708f6cff742da52f4010

OMAP3: set UYVY format for YUV422I CameraSource

OMX.TI.Video.encode uses YUV422ILE(Little endian) for encording.
So setting YCbYCr caused the incorrect color issue when decoding
the encoded video clip.

Signed-off-by: keun-o.park <sahara@ti.com>

Patch Set 5: Simple cherry-pick; no changes made. Taking approvals,
verifications and build test from patch set 4.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Iad509f0b4d96ec7f4c87c52765043e8281a79917

Fix for EOS buffer sending in Thumbnail mode

In case of thumbnail we are providing 2 codec config buffers and one data buffer.
The data buffer has EOS flag which triggers the decoding and flushing on the output
port. It was seen that the input buffer also gets an callback. This was causing next
input buffer to be send with EOS which is not desired. We want to send only 1 input
buffer.

Signed-off-by: Dandawate Saket <dsaket@ti.com>

Patch Set 2: Removing whitespace errors.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Patch Set 3: Review comment fix

Patch Set 4: White space removal

Signed-off-by: Dandawate Saket <dsaket@ti.com>

Patch Set 6:  Simple cherry-pick.  No changes made.  Taking
approvals and verifications from pathc set 5.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic520417621fd4086061a5d8f4185b3d24155c926

Gingerbread Camcorder : Support for MPEG4 Encoder

Description : Adds support for MPEG4 encoder.

Signed Off By : Sreenidhi Koti <Sreenidhi@ti.com>

Patch set 4: Simple cherry-pick on current tree.  No changes
made.  Taking verifications and approvals from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I2b8c22c3426511bfe5843668885e45afae716297

stagefright: remove memcpy from mp4 parser to OMX input buffer

For AV playback, mem copy from MP4 parser to OMX is a cost operation,
this patch avoided the intermediate copy from MPEG4Source to OMX I/P
which is currently configured to use Tiler 1D buffers, audio and NAL
fragments/multi-slice mode are not impacted by this optimization.

DR#OMAPS00232517

Signed-off-by: Yong Zhi <y-zhi@ti.com>

Patch Set 5: Simple cherry-pick on current tree.  No changes made.
Taking approvals, verifications and build test from patch set 4.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I4716d16f64f164d09f7cb6f45f2f051e6f0add33

MPEG4 parser changes for ctts structure

Description: These changes are ported from Froyo.
Change details:
MPEG4 parser currently doesnt understand the ctts structure. If decode
timestamp is not sample as presentation timestamp then the frames will
be presented to AV sync logic in wrong order.

The mp4 parser mandates to take into account the ctts if the decode &
display timestamps are not same.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on current head of tree.  No changes
made.  Taking verifications and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I53c3339f8fcba937ac3ddc13ea6810719703ff23

OMXCodec pause/resume scenario handling

Description# For OMXCodec source, there is a pause state, but
there is no explicit resume state. On resume of Awesomeplayer,
the OMXCodec is resumed on first read call from AwesomePlayer.
During this pause/resume transitions, on few iterations, there
is a starvation of Codec for buffers on the input port, because of previous
EMPTY_BUFFER_DONE call back couldn't initiate buffer to Codec,
because of Pause assertion. This is fixed by initiating the
buffer flow on I/P port in read method if the OMXCodec is resumed
from pause state.

Validation# Tested AV playback pause/resume multiple times.

patchset2# moved input buffer drain logic before filloutput buffer
to avoid deadlock.

Change-Id: Id0e72e346b1c9b50e4118007f01ca4ee0610bf75
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

SF: removing race condition of setting mOwnedByComponent

This fixes a race condition of setting mOwnedByComponent value.
Without this fix, setting mOwnedByComponent at the return of
fill_buffer() call sometimes lose in the race with FillBufferDone
call which also tries to set mOwnedByComponent.
To avoid the race condition and keep proper meaning of
mOwnedByComponent, mOwnedByComponent line should be placed right
before the fill_buffer() or emtpy_buffer() call.

Signed-off-by: keun-o.park <sahara@ti.com>

Patch set 3: Simple cherry-pick on the current tree.  No changes
made.  Taking verifications, approvals and build test from patch
set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I49a3fd18f7fac48d53956f8294e302f7362be641

Stagefright: Putting back memcpy from a previous change for OMAP3

This change will put back a memcpy removed by a previous change by
setting the changes to be target specific.

Signed-off-by: Juan Escamilla <juan.escamilla@ti.com>

Patch set 3:  Simple cherry-pick on current tree.  Taking approvals,
verfication and build test from previous patch set.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Id1a11c4f85482da2eb2e07057b49e96fda6f094a

OMAP3: enable two ITTIAM encoder codecs

This patch enables the two ITTIAM encoder.
OMX.ITTIAM.AAC.encode
OMX.TI.720P.Encoder

Change-Id: I84533191575e7f3be847f5dffb64d7038eb1e7b8
Signed-off-by: keun-o.park <sahara@ti.com>

Camcorder : Support for No Audio feature in MediaRecorder

By default NB-AMR is enabled for No-audio.
This patch prevents setting of Audio Encoder Parameters for No-Audio option.
This patch ports below patch from Froyo to Gingerbread.
http://review.omapzoom.org/#change,5318

Patchset-2 Adds check for SystemProperties.OMAP_ENHANCEMENT

Signed-off-by : Kalpesh Patil <kalpeshpatil@ti.com>

Change-Id: I408c25ba5d758bd222f4e006ee7e3a7de938927b

FM UI framework changes for FM Rx GUI

The changes are done under OMAP_ENHANCEMENT flag for FM+ Multimedia combo use cases.

cherry picked from p-froyo commit-id 541a8145f7994b59b9334d53a0448f0e43a3d4bb

Change-Id: I5c9f0be1257e855dcd3341eae7eaeb9a01b18906
Signed-off-by: Shitiz Kumar <shitiz_kumar@ti.com>

Disable capture message types before stopping preview

If we try to stopPreview in the middle of capture, these
callbacks might occur. In this case, stopPreview will already be
holding mLock while the message handler will try to grab mLock.
Deadlock occurs if the stopPreview and message callback dependencies
are in the same thread.

Issue reproduced with Image Capture/Home Key scenario.

DR: 229853
Patch Set 2:  Simple cherry-pick on current tree.  No changes made.
Taking approvals, build test and verifications from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I222d00f8bd69c11302a35610095efe0ddc49f876

OMAP3: CameraService: Set timeout to lockIfmessageWanted()

- This prevents from entering into infinite loop often.
One reason for this is  when trying to lock the mLock in
CameraService::Client::notifyCallback() and in the same time
CameraService::Client::sendCommand() grabs mLock. In CameraHal we never return
from CameraHal::sendCommand(), because we wait for callback from previewthread,
which is locked in mNotifyCb(), which actually waits infinitely for
mLock.tryLock() in CameraService::Client::lockIfMessageWanted(). So we never
release mLock in CameraHal::sendCommand().

Change-Id: I3d5014a44b47ed0571ffdd062c9671938953fb2c
Signed-off-by: Julian Shandorov <jshandorov@mm-sol.com>

OMAP4: Adding support for 3D images extension (JPS/MPO) for gallery application

Change-Id: I8d3ef643a12c83b3acc1159ac6700e1470b26353
Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

OMAP4: S3D: Add support for S3D Images extension (JPS/MPO) for Android Framework

Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

Patch set 5:  Simple rebase on current tree.  No changes made.
Taking approvals and verification from previous patch set.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ic430500e9693db116f44e2c630319056323c8e16

OMXCodec::read() to wait indefinitely when executing flash use case.

Issue: Recently, the conditional wait [ mBufferFilled.wait() ] in OMXCodec::read()
was replaced with a timed wait call [ mBufferFilled.waitRelative() ]. This breaks
pause-resume functionality during flash video playback.

Root cause: Flash and Awesome Player handle pause in a different manner.
In the case of AwesomePlayer, when the user pauses the video, AwesomePlayer
implements pause by not calling OMXCodec::read(). Flash implements pause by not
providing any input data. Flash calls OMXCodec::read() even during pause state.
When  OMXCodec:: read() times out and returns an error, flash exits the
video_decode thread, resulting in a hang.

Solution: For flash usecases, we are replacing mBufferFilled.waitRelative() with
mBufferFilled.wait(). That is, we will wait indefinitely.

This issue has been discussed with Adobe and they are open to handling this
scenario in a different manner. However, since it is past their code freeze date,
no changes can be made in flash codebase for the WASABI release. Hence we will
put in this temporary fix now and revert/update it later when adobe makes the
necessary changes.

Signed-off-by: Anu Sundararajan <sanuradha@ti.com>

Patch Set 2: Simple cherry-pick on current tree.  No changes made.
Takin verifications and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I461bc8a944a050ab9cd8fcfc28e3e1d5774e3067

Making MPEG4Writer understand out of order streams

Current mp4 writer doesnt understand out of order frames which is caused
due to insertion of BFrames in codecs

B frames is a bidirection frame and is dependent on the next frame to decode
itself

Current issue is the on turning on the B frames in encoder the timestamps
at the output of the encoder gets organized in a pattern.
e.g of 2 b frames
I/p of encoder I B1 B2 P [0 33 66 99]
O/p of encoder I P B1 B2 [0 99 33 66]

So normal decode timestamp is 99 - 0 , 33 - 66 , 66 - 33
Now we will have negative delta for 33 - 66 which will be encoded.

This is going to cause issue when presented to decoder as we will loose
sign anyways. Standard doesnt allow negative delta encoding in stts structure

So we have to sort the timestamps and then make the stts structure.
Then make a ctts structure which will hold the offset from the decode TS

Signed-off-by: Dandawate Saket <dsaket@ti.com>

Patch set 6: Addressed Dan's comments and cherry-picked on current
tree.  Taking approvals and verifications from patch set 5.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I1a0eeec83af6cd0e340d29a00bd9f74549eefb90

GB Camcorder : Fix AV-Sync Issue in camcorder

Description : 1) Stagefright recorder spawns two threads to record audio & video tracks independently.

2) Both the threads are scheduled with the standard Linux time-sharing schedule attribute SCHED_OTHER.

3) In the current implementation Audio track thread is created first followed by the video track thread.

4) The audio player is NOT started untill stagefright issues Play() command. This command is called when both
AUdio & Video sources are initialized & their respective threads are ready to run.

5) Since the Audio track thread is initialized before video thread, the dynamic priority of the thread keeps increasing every quantum
it's ready to run but being blocked by the scheduler (As the Audio Player start command is still not issued).

6) Once the Audio player is initialized, the scheduler allows the audio thread to execute for some time quantum
& the audio thread starts reading the data immediatly.

7) At this point Video track is still not started & is blocked to execute by the scheduler.

8) By the time video gets to execute, Audio has already filled approx 512 msec of data (At 128 msec intervals, 8Khz sample rate) . And there is an offset of
half a second.

9) So we will hear the Audio half a second after the video, when Audio & video are played back at the same time.

This patch reverses the creation sequence of Audio & Video, so that video is created first & allowed to execute for few time quantums before audio starts.
Since the update frequency of video TS are fast as compared to audio (33 msec), we will have only few video frames started early when compared to Audio.
This gives perfect AV-Sync when Played back. The actual reason on why Google has cerated Audio before video for REcord needs to be examined.

Defect Id : OMAPS00233256

Verified on AAC & NB-AMR audio codecs with different resolution, Frame rates & all video codecs (H264, H263 & MPEG4).
Verified AV-Sync for short duration (10 secs) & long duration (10 mins)

Signed Off By : Sreenidhi Koti <sreenidhi@ti.com>

Change-Id: I10a64f5c5e202164157b0af8ef245479d2af3388

SF high res/bitrate av streaming support

AwesomePlayer has to wait for 10 sec amount of data being buffered to start playing,
currently NuCachedSource2's kHighWaterThreashold is configured to 5M bytes, this is
less than 10 sec for high bitrate playback duration, so AwesomePlayer is not able to
complete prepare phase, the patch made modification of following parameters:

1. NuCachedSource2/kHighWaterThreshold - sum of max prefetched bytes + gray area,
   changed to 13M to buffer 6 - 10 sec duration.
2. NuCachedSouece2/kLowWaterThreshold - threshhold value to trigger prefetch,
   changed to 3M, AwesomePlayer will pause if prefeched duration is less than 2 sec
3. AweSomePlayer/kHighWaterMarkUs - cached duration to start playback or seek,
   reduced to 6 sec based on 1 and 2, this is also good for seek experience.

Defect: OMAPS00231728

Signed-off-by: Yong Zhi <y-zhi@ti.com>

Patch Set 3:  Cherry-picked on current tree. No changes made.  Taking
build test, approvals and verification from patch set 2.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: Ide2b7be7e1fffd2c3de1235df2448de993d18b12

libstagefright: fix lock-up condition for av streaming

This fix lock-up condition when AwesomePlayer is waiting for NuCachedSource2 to fill more data
while NuCachedSource2 is above kLowWaterThreshold and enters idle. Also increased kGrayArea,
this value is determined by max video resolution and worst case media layout, 3Mb is about good
enough to handle web oriented clips. This is a re-work of patch #11177 which has mirror update
conflicts.

Change-Id: Ifcd985499e7695f4971e750f3a8c5c5b6fcc8568
Signed-off-by: Yong Zhi <y-zhi@ti.com>

AwesomePlayer enum correction on GingerBread

Description: AwesomePlayer state machine enum is corrected to avoid
conflicts with the default enum values.

Validation# AV Playback from Android Gallery app

Change-Id: I9b292b9d58970a6ce77e6638fa2ede937c554f99
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Stagefright: Handling playback negative seek scenario

The changes are for porting the below patch from Froyo to Gingerbread
----------------------------------------------------------
http://review.omapzoom.org/#change,5711

This patch has change to fix the issue while performing
the stagefright "b 3" tests. They were failing as negative
offset was calculated and used for seek.

Actually in the SF middleware we have condition to check the
parameters. If the seek value is < 0, then android assert is
triggerred which leads to the issue. Actually as per the test app,
the test has to seek and continue decoding till the EOF.
Hence have modified the seek position handling accordingly.
-----------------------------------------------------------

Change-Id: I0fdd8391f1134b91f7c0c03f635de97fb8b7b2cc
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

StageFright: Skip zero size chunks in mp4 parser

Some mp4 clips were not playing with error ERROR_MALFORMED
returned from stagefright mp4 parser. These clips had zero
size chunks which the parser was not skipping. The patch
achieves this. I can share the clips if needed.

CSR#OMAPS00234409

Change-Id: Ifd9d99f735b642e8c6c9951bf35a79ec8c995453
Signed-off-by: Srinivas Spurthi G <spurthi.gs@ti.com>

Stagefright parser fix: fixes to play currently failing MP4 files The changes are for porting the below patch from Froyo to Gingerbread ---------------------------------------------------------- http://review.omapzoom.org/#change,10609

- ftypwmf
Few MP4 files have filetype atom as "ftypwmf". Not standard as per www.ftyps.com, but we have test samples with such headers.
Either we accept it like above, or don.t return error if we get valid MOOV or MDAT atoms later.

- mdat check
Few MP4 containes, don.t have filetype atom "ftyp" at all.
Don.t return error ahead, see if we have valid MDAT or other valid atom types. (opencore mp4 parser behavior. Path: opencore/fileformats/mp4)
----------------------------------------------------------

Patchset2# Added OMAP_ENHANCEMENT FLAG
Patchset3# Corrected LOGE macro.

Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Patch Set 4: Cherry-picked on current tree.  No changes made.
Taking approvals, verifications and build test.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I058696f93e2429ea99020285c289706c3027b9af

SF: configure kPadding for high-profile AV streaming

During AV seek, if one track's buffer being read first, suppose this
is video, and if the corresponding audio chunk happens to be ahead of
video offset, then there is cache miss, to counter this penalty, kPadding
is used to read 32K bytes adhed of the requested position, adjusted to 768k
to cope better with 720p/1080p.

Signed-off-by: Yong Zhi <y-zhi@ti.com>

Patch set 2:  Simple cherry-pick - no changes made.  Taking
approvals, verification and build test from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I41de69ff0a81aa7dcf32b4e22f205c3b456232d5

SF: AV streaming bug fix for ERROR_END_OF_STREAM condition

When mFinalStatus is ERROR_END_OF_STREAM, the avail size could still be greater
than the requested size in both single track and multiple track cases, so move
the evaluate and copy block ahead of error checking, this patch also pushed go
google for review (#21967).

DR#OMAPS00234827

Change-Id: I475f15fab844ade2980e67fee6461be25224cc8e
Signed-off-by: Yong Zhi <y-zhi@ti.com>

stagefright: OMXCodec changes to resolve regression in port reconfig

The patch addresses two issues.
1. Due to recent changes to support pause/resume state awareness in OMXCodec
port reconfig funtionality is impacted.
2. There is a race condition occuring some times due to which
we receive multiple times INFO_FORMAT_CHANGED from OMXCodec::read()
leading playback failure.

Verified sanity on AV playback/thumbnail generation

Fixes DR#OMAPS00235166

Change-Id: If9f4421a8ab0b04ef24afc84552df21904616b07
Signed-off-by:<dnk.mohan@ti.com>

720P HW Codec should be used for H264 BP video which H or W is bigger than 864.

Stagefright always select OMX.TI.Video.Decoder for H264 BP video if its resolution
is smaller than 864x480.
But since the supported Width and Height by  OMX.TI.Video.Decoder is up tp 864,
we need to use 720P.Video.Decoder for H264 BP Video which resolution is smaller than
864x480 but the Height or Width is bigger than 864.
This patch adds this if-condition.

Ref:OMAPS00243751

Patch Set 2:  Simple cherry-pick on current tree.  No changes made.
Taking approvals, verifications and build test from previous patch
sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: If6637bdd0dd37d6642a5f0f1c3fde3313ad901da

MPEG4 Sniffers fixes for files with only Audio tracks

Description# There are two fixes as part of this patch:
(1) In positionFileAtAtom method we are checking for atom size
to be > 8. But there are few atoms like "free", "wide" etc
which could be of size 8.The comparision is corrected
to  >= 8.
(2) And there are few clips which are having only audio traks.
There are no video traks hence the confidence is never changed
to 0.4; this would cause those clips failing to get
detected correctly.

DRT# OMAPS00238282 - MPEG4 sniffer confidence issue

Change-Id: I9cc5da12c35f35fb68ed609c63381de6c43f3f84
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Stagefright changes to support SoftwareCodecs for thumbnail mode

Description# findMatchingCodecs method in OMXCodec is modified to remove:
the hardcoding of Hardware codecs irrespetive of the quirk.
And capture frame method during thumbnail generation is modified
to remove the unnecessary logic which was forcing the first frame for
thumbnail if it fails during s/w decoding.

DRT# OMAPS00241143-Thumbnails generation of h263,mpg4,h264 of
resolution 32x32  results in media server died

Change-Id: I549edfbb813ea15554a30407f3e07596b41412d4
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

Gingerbread Camcorder: Fix first I-Frame corruption issue for H264 in GB camcorder

Description : The ducati codec mandatorily returns the first frame as IDR frame after codec config.
              GB writer extracts the sequence & picture param set info only from the codec config.
              And doesn't expect this info to be present in the consequent I-frame. Since our codec
              always sends the first frame as IDR frame, it has extra SPS, PPS & SEI specific
              info which GB writer does not understand.

             This was causing the GB writer to add these extra info as data & eventually
             corrupting the I-frame.

             This patch strips off the extra info from the IDR frames so that the parser gets the
             info thay way it desires. This patch (along with ducati patch) also fixes the seek issue
             for H264 encoder when 4 Motion Vector is enabled. The corresponding ducati patch is:
             https://android.dal.design.ti.com/#change,385

Signed Off By : Sreenidhi Koti <sreenidhi@ti.com>

Change-Id: Ibff4060afb3809e6a811dfdcb04d954803ade1cc

Adding support for the 3gpp2 file format

Adding "ftyp3g2" to the Mpeg4FileTypeList to add support for 3gpp2 (.3g2) files
OMAPS00231859

Change-Id: I797e2daf910df38577fa6dfe411edae8f5da1a55
Signed-off-by: Juan Escamilla <juan.escamilla@ti.com>

Stagefright: Add "skm2" into known ftyp types for MPEG4 extractor

In mpeg4extractor ftyp type "skm2" was not there.
Found one customer clip not being played due to this.
Added it to knownFileTypes.

Verified sanity on AV playback and thumbnail generation.

Change-Id: I92994902474be1f44922d5265fbc32ad4b9d598e
Signed-off-by:<dnk.mohan@ti.com>

Stagefright: Add "avc" into known ftyp types for MPEG4 extractor

In mpeg4extractor ftyp type "avc" was not there.
Some of the customer clips are not being played due to this.
Hence added it to knownFileTypes.

Verified sanity on AV playback and thumbnail generation.

Fixes DR#OMAPS00237169

Patchset2: Had further check on availbale ftyp types.
There is no all inclusive list available. But over time
we have covered most of them.Corrected avc to avc1 as there
are no other versions(like avc2, avc3 etc) avialble.
There are two types with iso : isom and iso2.Hence made changed
check for iso.

Change-Id: I4e7919b11ab960aeb5da8ff1c1e15a0e7d1256bd
Signed-off-by:<dnk.mohan@ti.com>

OMAP4: S3D: Restoring SEI message to IDR frames

	Note: S3D decoder relies first SEI message on IDR frame
	      to configure the display driver.

Signed-off-by: Gilles-Arnaud Bleu-Laine <gilles@ti.com>

Patch Set 5: Simple cherry-pick on current tree.  No changes made.
Taking verification and approvals from previous patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I53d9a17c2a17b54e5511ec721c9c44ec5ab2caa8

OMAP3: SF: handling multiple NALs in a output buffer

In case of Ittiam's 720P encoder, it returns the output which has
multiple NALs in itself. And, these multiple NALs has a start code
for each NAL to parse each NAL unit. This patch make MPEG4Writer
be able to handle multiple NALs in a output buffer properly.

Change-Id: I58b285946c4e735cac53aee77c119783536a1942
Signed-off-by: keun-o.park <sahara@ti.com>

Gingerbread Camcorder : Support for H.264 Encoder - High Profile

This patch makes H264-High-profile as default profile for H264 Encoder.
A check was commented in MPEG4Writer which prevents H264-High-profile encoding.

Signed-off-by : Kalpesh Patil <kalpeshpatil@ti.com>

Patch set 2:  Simple cherry-pick onto current tree.  No changes made.
Taking verifications and approvals from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Patch set 3: Rebase again as previous patch rebased.  Taking approvals
and verifications from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>

Change-Id: I5f71dd84cab8e03dbb25687d7bfa0c14c160caf7

OMAP3:SF Fix for 1st frame corruption in MPEG4 encoding.

Discard the buffer after receiving the codec specific data.
Else this will lead to writing of wrong entries into
the stss, stsz & other atoms. Which causes the playback
of first 1 second of clip to be blank on QuickTime.
TI Video encoder and Ittiam Video encoder sends only the codec
specific data in the first buffer now. But, it still doesn't
have the codec specific data flag set yet.

Change-Id: I4174d50d7db6e866c30c0791581dcf81dca98c01
Signed-off-by: Vikram Simha <vikram.simha@ti.com>
Signed-off-by: keun-o.park <sahara@ti.com>

MPEG4 Writer changes to reduce time taken for Stts and Ctts Writes

With Current implementation, in the for loops for entering Stts Entry as
well as Ctts entry, the check for iterator was the List.size() call. This
API is implemented to iterate throught the list and return the size. So when
we iterate through list of size more than 10000 ( around 10 min record ) this
iterator check added significant delay and hence TN generation was taking
close to 1 min for a 10 min Video.

This patch removes the uncessary List.size() and saves the size beforehand
in a local variable.

Fix for DR: OMAPS00241059

Signed-off-by: Sathya Prakash M R <a0393677@ti.com>

Patch Set 2:  Simple cherry-pick on current tree. No changes made.
Taking approvals, verifications and build test from patch set 1.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I13d8438024b7841b2590179a8defb228f82b0592

Update Timestamps based on sample counts

For non 1080p clips we are seein that the sample count is
comming to be non zero quite often. This was causing a
drift in timestamp. Added correction in finding difference
in timestamp. This is bug in implementation and was missed.

Change-Id: I3e8e2e5bdb2621217f629d2a017a39c21f1c35d9
Signed-off-by: Dandawate Saket <dsaket@ti.com>

Mpeg4 doesnt meet the PPM target

Mpeg4 ppm clips dont meet the validation criteria of 30fps.
The issue was found to be in ctts structure not added to the
stts structure causing wrong time stamp to be presented to
the decoder. This was done only for H264 and not for mpeg4.

DRT: OMAPS00229150
patchset2: fixed review comments.

Change-Id: I71112f48564ad8f778628bfd59bc11c59fcdce6d
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>

libstagefright: Discard SEI messages after getting the frame packing

we don't recognize anything else, anyway, and some messages confuse
the parser

Change-Id: Ie74f5fa9dc3b50cc7108f4b252faaacf716a4c60

OMAP3: StagefrightRecoder: limit Max-bitrate by H.264 profile level.

 When the H.264 recording of Camera is freezed and hanged.
 (In case of, set high bitrate to low resolution)
 In the CODEC side, codec waiting for corresponding bitrate by profile level.
    - Added encoding parameters table.
    - find corresponding bitrate by calculated level and limit max-bitrate

Signed-off-by: Min-su.Kim <x0154824@ti.com>

Patch Set 4: Simple cherry-pick on current tree.  No changes made.
Taking verifications and approvals from previous patch sets.  Build
test done in patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I704cbe858e8498f41497a48a0c54428da9613a01

OMAP: Configuring sample rate appropriatetly for AMR-WB record

StagefrightRecorder was setting the sample rate incorrectly for
AMR-WB speech codec. This change will configure this setting
accordingly.

Change-Id: Ibef47106b84a026719edcc001cfe75ddbeeff4c7
Signed-off-by: Juan Escamilla <juan.escamilla@ti.com>
Signed-off-by: Ricky Bhatia <a0866433@ti.com>

OMAP3: Support FW3A libcamera blobs

FW3A libcameras support a number of extended parameters, but do
not respect the standard API.
camera-omap3 includes support for fw3a, but it requires a set of headers
and libraries that aren't publicly available, so use
BOARD_HAS_OMAP3_FW3A_LIBCAMERA to enable the blob

Change-Id: Ic6e6b88576a538e015ae77eb1fd9fe9ea186a3c4

StageFright: Support for Ittiam AAC encode

This patch is used to enable Ittiam AAC encode at SF level
patch set 3- remove commented out code for wbamr encoder

Signed-off-by: Richard Gong <rgong@ti.com>

Patch Set 4:  Simple cherry-pick on current tree.  No changes made.
Taking approvals, verification and build test from patch set 3.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I5c8cddee193f69d2e69530c05b8b9e6456419738

OMAP3: SF: Fix wrong condition check for WMV decoder

This fixes the wrong condition check in the OMXCodec.
And, this makes SF select proper codec by a resolution size.

Signed-off-by: Sumukh HS <sumukh.hs@ittiam.com>
Signed-off-by: keun-o.park <sahara@ti.com>

Patch set 4: Simple cherry-pick on current tree.  No changes made.
Taking verifications, approvals and build test from previous
patch sets.
Signed-off-by: Jean Johnson <jean-johnson@ti.com>
Change-Id: I7b5786b15dadae06a8241dcf0d02a9fb4d2f053b

OMAP3: Allow a device to set its own number of overlay buffers

This uses the same build-time variable as the corresponding liboverlay
change

Change-Id: Ia477f7ac3901ca64e7af46a7b6ac004b64f33c95

Change-Id: Iedba0187175e333d69d3348d2917c40fbf6a5d27
commit 1a6862fda91d5bc0987d32ab3410a32badcb861e 1 parent 8d9994ab18
rmcc authored

Showing 122 changed files with 9,593 additions and 170 deletions.

M core/java/android/hardware/Camera.java 4
M core/java/android/os/SystemProperties.java 1
M core/java/android/widget/VideoView.java 105
M core/jni/android_hardware_Camera.cpp 10
M include/camera/Camera.h 17
M include/camera/CameraHardwareInterface.h 11
M include/camera/ICameraClient.h 5
M include/media/AudioSystem.h 24
M include/media/IAudioFlinger.h 7
M include/media/IMediaPlayer.h 3
M include/media/IMediaPlayerService.h 6
M include/media/IOMX.h 38
M include/media/MediaPlayerInterface.h 4
M include/media/MediaProfiles.h 4
A include/media/OverlayRenderer.h 127
M include/media/mediaplayer.h 3
M include/media/mediarecorder.h 5
M include/media/stagefright/AudioPlayer.h 8
M include/media/stagefright/CameraSource.h 9
M include/media/stagefright/ColorConverter.h 16
M include/media/stagefright/HardwareAPI.h 18
M include/media/stagefright/MediaDefs.h 15
M include/media/stagefright/MediaErrors.h 3
M include/media/stagefright/MediaExtractor.h 16
M include/media/stagefright/MediaSource.h 20
M include/media/stagefright/MetaData.h 19
M include/media/stagefright/OMXCodec.h 109
M include/media/stagefright/Utils.h 38
M include/media/stagefright/VideoRenderer.h 23
M include/media/stagefright/openmax/OMX_Index.h 1
M include/surfaceflinger/ISurface.h 12
M include/surfaceflinger/Surface.h 12
M include/ui/FramebufferNativeWindow.h 19
M include/ui/Overlay.h 3
M libs/camera/Camera.cpp 9
M libs/camera/ICameraClient.cpp 17
M libs/surfaceflinger_client/ISurface.cpp 70
M libs/ui/FramebufferNativeWindow.cpp 147
M libs/ui/Overlay.cpp 8
M media/java/android/media/AudioService.java 91
M media/java/android/media/AudioSystem.java 4
M media/java/android/media/DecoderCapabilities.java 2
M media/java/android/media/MediaFile.java 67
M media/java/android/media/MediaRecorder.java 24
M media/java/android/media/MediaScanner.java 5
M media/java/android/media/ThumbnailUtils.java 5
M media/libmedia/Android.mk 8
M media/libmedia/IAudioFlinger.cpp 22
M media/libmedia/IMediaPlayer.cpp 23
M media/libmedia/IMediaPlayerService.cpp 27
M media/libmedia/IOMX.cpp 142
M media/libmedia/MediaProfiles.cpp 4
A media/libmedia/OverlayRenderer.cpp 608
M media/libmedia/mediaplayer.cpp 12
M media/libmediaplayerservice/Android.mk 8
M media/libmediaplayerservice/MediaPlayerService.cpp 40
M media/libmediaplayerservice/MediaPlayerService.h 13
M media/libmediaplayerservice/StagefrightPlayer.cpp 6
M media/libmediaplayerservice/StagefrightPlayer.h 3
M media/libmediaplayerservice/StagefrightRecorder.cpp 140
A media/libstagefright/ASFExtractor.cpp 179
M media/libstagefright/Android.mk 31
M media/libstagefright/AudioPlayer.cpp 72
M media/libstagefright/AwesomePlayer.cpp 756
M media/libstagefright/CameraSource.cpp 126
M media/libstagefright/DataSource.cpp 9
M media/libstagefright/MPEG4Extractor.cpp 703
M media/libstagefright/MPEG4Writer.cpp 325
M media/libstagefright/MediaBuffer.cpp 15
M media/libstagefright/MediaDefs.cpp 15
M media/libstagefright/MediaExtractor.cpp 14
M media/libstagefright/MediaSource.cpp 13
M media/libstagefright/NuCachedSource2.cpp 19
M media/libstagefright/OMXCodec.cpp 1,872
M media/libstagefright/SampleTable.cpp 69
M media/libstagefright/StagefrightMediaScanner.cpp 3
M media/libstagefright/StagefrightMetadataRetriever.cpp 113
A media/libstagefright/TISEIMessagesParser.cpp 560
A media/libstagefright/TIVideoConfigParser.cpp 596
M media/libstagefright/WAVExtractor.cpp 18
M media/libstagefright/codecs/mp3dec/Android.mk 5
M media/libstagefright/colorconversion/Android.mk 8
M media/libstagefright/colorconversion/ColorConverter.cpp 111
M media/libstagefright/colorconversion/SoftwareRenderer.cpp 8
M media/libstagefright/id3/Android.mk 3
A media/libstagefright/include/ASFExtractor.h 93
M media/libstagefright/include/AwesomePlayer.h 54
M media/libstagefright/include/NuCachedSource2.h 5
M media/libstagefright/include/OMX.h 16
M media/libstagefright/include/OMXNodeInstance.h 6
M media/libstagefright/include/SampleTable.h 14
M media/libstagefright/include/SoftwareRenderer.h 5
A media/libstagefright/include/TISEIMessagesParser.h 88
M media/libstagefright/omx/OMX.cpp 133
M media/libstagefright/omx/OMXNodeInstance.cpp 32
M media/libstagefright/omx/OMXRenderer.h 8
A omapmmlib/Android.mk 44
A omapmmlib/com.ti.omap.omap_mm_library.xml 5
A omapmmlib/java/com/ti/omap/omap_mm_library/OmapMMLibrary.java 65
A omapmmlib/java/com/ti/omap/omap_mm_library/UiCloningService.java 71
A omapmmlib/jni/Android.mk 61
A omapmmlib/jni/OmapMMLibrary.cpp 309
A omapmmlib/jni/UiCloningService.cpp 203
M services/audioflinger/AudioFlinger.cpp 47
M services/audioflinger/AudioFlinger.h 13
M services/audioflinger/AudioPolicyService.cpp 16
M services/audioflinger/AudioPolicyService.h 7
M services/camera/libcameraservice/Android.mk 8
M services/camera/libcameraservice/CameraService.cpp 225
M services/camera/libcameraservice/CameraService.h 31
M services/camera/tests/CameraServiceTest/CameraServiceTest.cpp 27
M services/java/com/android/server/NotificationManagerService.java 28
M services/java/com/android/server/NotificationPlayer.java 16
M services/sensorservice/Android.mk 5
M services/sensorservice/SensorDevice.cpp 9
M services/surfaceflinger/Android.mk 2
M services/surfaceflinger/LayerBase.cpp 20
M services/surfaceflinger/LayerBase.h 7
M services/surfaceflinger/LayerBuffer.cpp 188
M services/surfaceflinger/LayerBuffer.h 27
M services/surfaceflinger/SurfaceFlinger.cpp 9
M services/surfaceflinger/SurfaceFlinger.h 3
Txt core/java/android/hardware/Camera.java
... ...
@@ -2763,6 +2763,10 @@ public class Camera {
2763 2763
                 /* Support NV cams */
2764 2764
                 KEY_ISO_MODE = "nv-picture-iso";
2765 2765
                 str = get(KEY_ISO_MODE + SUPPORTED_VALUES_SUFFIX);
  2766
+            } else if (str == null && get("iso-mode-values") != null) {
  2767
+                /* Support OMAP cams */
  2768
+                KEY_ISO_MODE = "iso-mode";
  2769
+                str = get(KEY_ISO_MODE + SUPPORTED_VALUES_SUFFIX);
2766 2770
             }
2767 2771
             return split(str);
2768 2772
         }
Txt core/java/android/os/SystemProperties.java
... ...
@@ -28,6 +28,7 @@ public class SystemProperties
28 28
 {
29 29
     public static final int PROP_NAME_MAX = 31;
30 30
     public static final int PROP_VALUE_MAX = 91;
  31
+    public static final boolean OMAP_ENHANCEMENT = native_get_boolean("com.ti.omap_enhancement", false);
31 32
 
32 33
     private static native String native_get(String key);
33 34
     private static native String native_get(String key, String def);
Txt core/java/android/widget/VideoView.java
... ...
@@ -35,10 +35,20 @@ import android.view.SurfaceHolder;
35 35
 import android.view.SurfaceView;
36 36
 import android.view.View;
37 37
 import android.widget.MediaController.MediaPlayerControl;
  38
+import android.content.BroadcastReceiver;
  39
+import android.content.IntentFilter;
  40
+import android.os.SystemProperties;
38 41
 
39 42
 import java.io.IOException;
40 43
 import java.util.Map;
41 44
 
  45
+/* TI custom package */
  46
+import com.ti.omap.omap_mm_library.OmapMMLibrary;
  47
+
  48
+/* TI FM UI port -start */
  49
+import android.os.SystemProperties;
  50
+/* TI FM UI port -stop */
  51
+
42 52
 /**
43 53
  * Displays a video file.  The VideoView class
44 54
  * can load images from various sources (such as resources or content
... ...
@@ -48,6 +58,10 @@ import java.util.Map;
48 58
  */
49 59
 public class VideoView extends SurfaceView implements MediaPlayerControl {
50 60
     private String TAG = "VideoView";
  61
+
  62
+    private OmapMMLibrary mOmapMMHandle = null;
  63
+    private IntentFilter mHdmiIntent = null;
  64
+
51 65
     // settable by the client
52 66
     private Uri         mUri;
53 67
     private Map<String, String> mHeaders;
... ...
@@ -65,6 +79,12 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
65 79
     private static final int STATE_RESUME             = 7;
66 80
     private static final int STATE_SUSPEND_UNSUPPORTED = 8;
67 81
 
  82
+    // All possible Display Types on OMAP4.
  83
+    private static final int DISPLAY_TYPE_LCD_PRIMARY   = 0x0000;
  84
+    private static final int DISPLAY_TYPE_LCD_SECONDARY = 0x0001;
  85
+    private static final int DISPLAY_TYPE_HDMI_TV       = 0x0002;
  86
+    private static final int DISPLAY_TYPE_PICO_DLP      = 0x0003;
  87
+
68 88
     // mCurrentState is a VideoView object's current state.
69 89
     // mTargetState is the state that a method caller intends to reach.
70 90
     // For instance, regardless the VideoView object's current state,
... ...
@@ -91,6 +111,10 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
91 111
     private boolean     mCanSeekForward;
92 112
     private int         mStateWhenSuspended;  //state before calling suspend()
93 113
 
  114
+    private static final String ACTION_HDMI_PLUG = "android.intent.action.HDMI_PLUG";
  115
+    // Broadcast receiver for device connections intent broadcasts
  116
+    private final BroadcastReceiver mReceiver = new VideoPlaybackBroadcastReceiver();
  117
+
94 118
     public VideoView(Context context) {
95 119
         super(context);
96 120
         initVideoView();
... ...
@@ -167,6 +191,14 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
167 191
         requestFocus();
168 192
         mCurrentState = STATE_IDLE;
169 193
         mTargetState  = STATE_IDLE;
  194
+
  195
+        if(SystemProperties.OMAP_ENHANCEMENT) {
  196
+            mOmapMMHandle = new OmapMMLibrary();
  197
+            //if the OmapMMHandle is non-null, initialise jni
  198
+            if (mOmapMMHandle != null) {
  199
+                mOmapMMHandle.native_init();
  200
+            }
  201
+        }
170 202
     }
171 203
 
172 204
     public void setVideoPath(String path) {
... ...
@@ -197,6 +229,19 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
197 229
             mCurrentState = STATE_IDLE;
198 230
             mTargetState  = STATE_IDLE;
199 231
         }
  232
+
  233
+        // Unregister for device HDMI-Hotplug intent broadcasts.
  234
+        if(SystemProperties.OMAP_ENHANCEMENT) {
  235
+            //unregister and delete the memory for hdmi intent
  236
+            if (mHdmiIntent != null) {
  237
+                mContext.unregisterReceiver(mReceiver);
  238
+                mHdmiIntent = null;
  239
+            }
  240
+            //delete the omapMMHandle memory
  241
+            if (mOmapMMHandle != null) {
  242
+                mOmapMMHandle = null;
  243
+            }
  244
+        }
200 245
     }
201 246
 
202 247
     private void openVideo() {
... ...
@@ -209,7 +254,14 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
209 254
         Intent i = new Intent("com.android.music.musicservicecommand");
210 255
         i.putExtra("command", "pause");
211 256
         mContext.sendBroadcast(i);
212  
-
  257
+        /* TI FM UI port -start */
  258
+        if (SystemProperties.OMAP_ENHANCEMENT) {
  259
+             // Tell the FM playback service to pause,as the video playback will start.
  260
+             // TODO: these constants need to be published somewhere in the framework.
  261
+             Intent fm = new Intent("com.ti.server.fmpausecmd");
  262
+             mContext.sendBroadcast(fm);
  263
+        }
  264
+        /* TI FM UI port -stop */
213 265
         // we shouldn't clear the target state, because somebody might have
214 266
         // called start() previously
215 267
         release(false);
... ...
@@ -231,6 +283,10 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
231 283
             // target state that was there before.
232 284
             mCurrentState = STATE_PREPARING;
233 285
             attachMediaController();
  286
+            if(SystemProperties.OMAP_ENHANCEMENT) {
  287
+                mOmapMMHandle.setVideoSurface(mSurfaceHolder);
  288
+                mOmapMMHandle.setMediaPlayer(mMediaPlayer);
  289
+            }
234 290
         } catch (IOException ex) {
235 291
             Log.w(TAG, "Unable to open content: " + mUri, ex);
236 292
             mCurrentState = STATE_ERROR;
... ...
@@ -278,7 +334,16 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
278 334
     MediaPlayer.OnPreparedListener mPreparedListener = new MediaPlayer.OnPreparedListener() {
279 335
         public void onPrepared(MediaPlayer mp) {
280 336
             mCurrentState = STATE_PREPARED;
281  
-
  337
+            /**
  338
+            * Register for device HDMI-Hotplug intent broadcasts.
  339
+            * the registration is delayed till the Media player is prepared.
  340
+            * This is required to avoid the scenario where the event is disptached
  341
+            * even before Overlay source is created.
  342
+            */
  343
+            if(SystemProperties.OMAP_ENHANCEMENT) {
  344
+                mHdmiIntent = new IntentFilter(ACTION_HDMI_PLUG);
  345
+                mContext.registerReceiver(mReceiver, mHdmiIntent);
  346
+            }
282 347
             // Get the capabilities of the player for this stream
283 348
             Metadata data = mp.getMetadata(MediaPlayer.METADATA_ALL,
284 349
                                       MediaPlayer.BYPASS_METADATA_FILTER);
... ...
@@ -477,6 +542,9 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
477 542
             if (mMediaPlayer != null && mCurrentState == STATE_SUSPEND
478 543
                    && mTargetState == STATE_RESUME) {
479 544
                 mMediaPlayer.setDisplay(mSurfaceHolder);
  545
+                if(SystemProperties.OMAP_ENHANCEMENT) {
  546
+                    mOmapMMHandle.setVideoSurface(mSurfaceHolder);
  547
+                 }
480 548
                 resume();
481 549
             } else {
482 550
                 openVideo();
... ...
@@ -606,6 +674,12 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
606 674
             if (mMediaPlayer.resume()) {
607 675
                 mCurrentState = mStateWhenSuspended;
608 676
                 mTargetState = mStateWhenSuspended;
  677
+                if(SystemProperties.OMAP_ENHANCEMENT) {
  678
+                    Intent hdmiIntent =  mContext.registerReceiver(null,
  679
+                                          new IntentFilter(ACTION_HDMI_PLUG));
  680
+                    mReceiver.onReceive(mContext, hdmiIntent);
  681
+                }
  682
+
609 683
             } else {
610 684
                 Log.w(TAG, "Unable to resume video");
611 685
             }
... ...
@@ -674,4 +748,31 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
674 748
     public boolean canSeekForward() {
675 749
         return mCanSeekForward;
676 750
     }
  751
+
  752
+    /**
  753
+     * Receiver for HDMI-Hotplug intent broadcasts
  754
+     */
  755
+    private class VideoPlaybackBroadcastReceiver extends BroadcastReceiver {
  756
+        @Override
  757
+        public void onReceive(Context context, Intent intent) {
  758
+            if (intent == null) {
  759
+                Log.e(TAG, "VideoPlaybackBroadcastReceiver intent is NULL!");
  760
+                return;
  761
+            }
  762
+            String action = intent.getAction();
  763
+
  764
+            if (SystemProperties.OMAP_ENHANCEMENT && action.equals(ACTION_HDMI_PLUG)) {
  765
+                int state = intent.getIntExtra("state", 0);
  766
+
  767
+                if(state==1) {
  768
+                    Log.d(TAG, "VideoPlaybackBroadcastReceiver.onReceive() : Switching to HDMI_TV)");
  769
+                    mOmapMMHandle.setDisplayId(DISPLAY_TYPE_HDMI_TV);
  770
+                } else {
  771
+                    Log.d(TAG, "VideoPlaybackBroadcastReceiver.onReceive() : Switching to LCD-Primary");
  772
+                    mOmapMMHandle.setDisplayId(DISPLAY_TYPE_LCD_PRIMARY);
  773
+                }
  774
+            }
  775
+        }
  776
+    }
  777
+
677 778
 }
Txt core/jni/android_hardware_Camera.cpp
... ...
@@ -50,7 +50,11 @@ public:
50 50
     ~JNICameraContext() { release(); }
51 51
     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
52 52
     virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr);
  53
+#ifdef OMAP_ENHANCEMENT
  54
+    virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr, uint32_t offset=0, uint32_t stride=0);
  55
+#else
53 56
     virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
  57
+#endif
54 58
     void addCallbackBuffer(JNIEnv *env, jbyteArray cbb);
55 59
     void setCallbackMode(JNIEnv *env, bool installed, bool manualMode);
56 60
     sp<Camera> getCamera() { Mutex::Autolock _l(mLock); return mCamera; }
... ...
@@ -227,8 +231,12 @@ void JNICameraContext::postData(int32_t msgType, const sp<IMemory>& dataPtr)
227 231
         break;
228 232
     }
229 233
 }
230  
-
  234
+#ifdef OMAP_ENHANCEMENT
  235
+void JNICameraContext::postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr,
  236
+        uint32_t offset, uint32_t stride)
  237
+#else
231 238
 void JNICameraContext::postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr)
  239
+#endif
232 240
 {
233 241
     // TODO: plumb up to Java. For now, just drop the timestamp
234 242
     postData(msgType, dataPtr);
Txt include/camera/Camera.h
... ...
@@ -78,6 +78,13 @@ enum {
78 78
     CAMERA_MSG_POSTVIEW_FRAME   = 0x040,
79 79
     CAMERA_MSG_RAW_IMAGE        = 0x080,
80 80
     CAMERA_MSG_COMPRESSED_IMAGE = 0x100,
  81
+
  82
+#ifdef OMAP_ENHANCEMENT
  83
+
  84
+    CAMERA_MSG_BURST_IMAGE      = 0x200,
  85
+
  86
+#endif
  87
+
81 88
     CAMERA_MSG_ALL_MSGS         = 0x1FF
82 89
 };
83 90
 
... ...
@@ -146,7 +153,12 @@ class CameraListener: virtual public RefBase
146 153
 public:
147 154
     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
148 155
     virtual void postData(int32_t msgType, const sp<IMemory>& dataPtr) = 0;
  156
+#ifdef OMAP_ENHANCEMENT
  157
+    virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr,
  158
+                    uint32_t offset=0, uint32_t stride=0) = 0;
  159
+#else
149 160
     virtual void postDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) = 0;
  161
+#endif
150 162
 };
151 163
 
152 164
 class Camera : public BnCameraClient, public IBinder::DeathRecipient
... ...
@@ -232,7 +244,12 @@ public:
232 244
     // ICameraClient interface
233 245
     virtual void        notifyCallback(int32_t msgType, int32_t ext, int32_t ext2);
234 246
     virtual void        dataCallback(int32_t msgType, const sp<IMemory>& dataPtr);
  247
+#ifdef OMAP_ENHANCEMENT
  248
+    virtual void        dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr,
  249
+                                uint32_t offset=0, uint32_t stride=0);
  250
+#else
235 251
     virtual void        dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
  252
+#endif
236 253
 
237 254
     sp<ICamera>         remote();
238 255
 
Txt include/camera/CameraHardwareInterface.h
... ...
@@ -46,12 +46,19 @@ typedef void (*notify_callback)(int32_t msgType,
46 46
 typedef void (*data_callback)(int32_t msgType,
47 47
                               const sp<IMemory>& dataPtr,
48 48
                               void* user);
49  
-
  49
+#ifdef OMAP_ENHANCEMENT
  50
+typedef void (*data_callback_timestamp)(nsecs_t timestamp,
  51
+                                        int32_t msgType,
  52
+                                        const sp<IMemory>& dataPtr,
  53
+                                        void* user,
  54
+                                        uint32_t offset,
  55
+                                        uint32_t stride);
  56
+#else
50 57
 typedef void (*data_callback_timestamp)(nsecs_t timestamp,
51 58
                                         int32_t msgType,
52 59
                                         const sp<IMemory>& dataPtr,
53 60
                                         void* user);
54  
-
  61
+#endif
55 62
 /**
56 63
  * CameraHardwareInterface.h defines the interface to the
57 64
  * camera hardware abstraction layer, used for setting and getting
Txt include/camera/ICameraClient.h
... ...
@@ -32,7 +32,12 @@ public:
32 32
 
33 33
     virtual void            notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) = 0;
34 34
     virtual void            dataCallback(int32_t msgType, const sp<IMemory>& data) = 0;
  35
+#ifdef OMAP_ENHANCEMENT
  36
+    virtual void            dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& data,
  37
+                                    uint32_t offset=0, uint32_t stride=0) = 0;
  38
+#else
35 39
     virtual void            dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& data) = 0;
  40
+#endif
36 41
 };
37 42
 
38 43
 // ----------------------------------------------------------------------------
Txt include/media/AudioSystem.h
... ...
@@ -145,12 +145,19 @@ public:
145 145
         CHANNEL_IN_Z_AXIS = 0x2000,
146 146
         CHANNEL_IN_VOICE_UPLINK = 0x4000,
147 147
         CHANNEL_IN_VOICE_DNLINK = 0x8000,
  148
+#ifdef OMAP_ENHANCEMENT
  149
+        CHANNEL_IN_VOICE_UPLINK_DNLINK = 0x10000,
  150
+#endif
148 151
         CHANNEL_IN_MONO = CHANNEL_IN_FRONT,
149 152
         CHANNEL_IN_STEREO = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT),
150 153
         CHANNEL_IN_ALL = (CHANNEL_IN_LEFT | CHANNEL_IN_RIGHT | CHANNEL_IN_FRONT | CHANNEL_IN_BACK|
151 154
                 CHANNEL_IN_LEFT_PROCESSED | CHANNEL_IN_RIGHT_PROCESSED | CHANNEL_IN_FRONT_PROCESSED | CHANNEL_IN_BACK_PROCESSED|
152 155
                 CHANNEL_IN_PRESSURE | CHANNEL_IN_X_AXIS | CHANNEL_IN_Y_AXIS | CHANNEL_IN_Z_AXIS |
153  
-                CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK)
  156
+#ifdef OMAP_ENHANCEMENT
  157
+                CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK | CHANNEL_IN_VOICE_UPLINK_DNLINK)
  158
+#else
  159
+                CHANNEL_IN_VOICE_UPLINK | CHANNEL_IN_VOICE_DNLINK )
  160
+#endif
154 161
     };
155 162
 
156 163
     enum audio_mode {
... ...
@@ -269,12 +276,15 @@ public:
269 276
         DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
270 277
         DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
271 278
         DEVICE_OUT_AUX_DIGITAL = 0x400,
272  
-        DEVICE_OUT_HDMI = 0x2000,
273 279
 #ifdef HAVE_FM_RADIO
274 280
         DEVICE_OUT_FM = 0x800,
275 281
         DEVICE_OUT_FM_SPEAKER = 0x1000,
276 282
         DEVICE_OUT_FM_ALL = (DEVICE_OUT_FM | DEVICE_OUT_FM_SPEAKER),
  283
+#elif defined(OMAP_ENHANCEMENT)
  284
+        DEVICE_OUT_FM_TRANSMIT = 0x800,
  285
+        DEVICE_OUT_LOW_POWER = 0x1000,
277 286
 #endif
  287
+        DEVICE_OUT_HDMI = 0x2000,
278 288
         DEVICE_OUT_DEFAULT = 0x8000,
279 289
         DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET |
280 290
 #ifdef HAVE_FM_RADIO
... ...
@@ -283,7 +293,12 @@ public:
283 293
                 DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
284 294
 #endif
285 295
                 DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
  296
+#ifdef OMAP_ENHANCEMENT
  297
+                DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | DEVICE_OUT_LOW_POWER |
  298
+                DEVICE_OUT_FM_TRANSMIT | DEVICE_OUT_DEFAULT),
  299
+#else
286 300
                 DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | DEVICE_OUT_HDMI | DEVICE_OUT_DEFAULT),
  301
+#endif
287 302
         DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
288 303
                 DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER),
289 304
 
... ...
@@ -300,12 +315,17 @@ public:
300 315
         DEVICE_IN_FM_RX = 0x1000000,
301 316
         DEVICE_IN_FM_RX_A2DP = 0x2000000,
302 317
 #endif
  318
+#ifdef OMAP_ENHANCEMENT
  319
+        DEVICE_IN_FM_ANALOG = 0x1000000,
  320
+#endif
303 321
         DEVICE_IN_DEFAULT = 0x80000000,
304 322
 
305 323
         DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC |
306 324
                 DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL |
307 325
 #ifdef HAVE_FM_RADIO
308 326
                 DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_FM_RX | DEVICE_IN_FM_RX_A2DP | DEVICE_IN_DEFAULT)
  327
+#elif OMAP_ENHANCEMENT
  328
+                DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC  | DEVICE_IN_FM_ANALOG | DEVICE_IN_DEFAULT)
309 329
 #else
310 330
                 DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT)
311 331
 #endif
Txt include/media/IAudioFlinger.h
... ...
@@ -91,7 +91,12 @@ public:
91 91
      */
92 92
     virtual     status_t    setStreamVolume(int stream, float value, int output) = 0;
93 93
     virtual     status_t    setStreamMute(int stream, bool muted) = 0;
94  
-
  94
+#ifdef OMAP_ENHANCEMENT
  95
+    /* This will tell playback thread that FM Rx is active
  96
+     * and device will not go to standby
  97
+     */
  98
+    virtual     status_t    setFMRxActive(bool state)=0;
  99
+#endif
95 100
     virtual     float       streamVolume(int stream, int output) const = 0;
96 101
     virtual     bool        streamMute(int stream) const = 0;
97 102
 
Txt include/media/IMediaPlayer.h
... ...
@@ -51,6 +51,9 @@ public:
51 51
     virtual status_t        setAuxEffectSendLevel(float level) = 0;
52 52
     virtual status_t        attachAuxEffect(int effectId) = 0;
53 53
 
  54
+#ifdef OMAP_ENHANCEMENT
  55
+    virtual status_t        requestVideoCloneMode(bool enable) = 0;
  56
+#endif
54 57
     // Invoke a generic method on the player by using opaque parcels
55 58
     // for the request and reply.
56 59
     // @param request Parcel that must start with the media player
Txt include/media/IMediaPlayerService.h
... ...
@@ -32,6 +32,9 @@ namespace android {
32 32
 
33 33
 class IMediaRecorder;
34 34
 class IOMX;
  35
+#ifdef OMAP_ENHANCEMENT
  36
+class IOverlayRenderer;
  37
+#endif
35 38
 
36 39
 class IMediaPlayerService: public IInterface
37 40
 {
... ...
@@ -48,6 +51,9 @@ public:
48 51
     virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
49 52
     virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat) = 0;
50 53
     virtual sp<IOMX>            getOMX() = 0;
  54
+#ifdef OMAP_ENHANCEMENT
  55
+    virtual sp<IOverlayRenderer>  getOverlayRenderer()=0;
  56
+#endif
51 57
 };
52 58
 
53 59
 // ----------------------------------------------------------------------------
Txt include/media/IOMX.h
... ...
@@ -137,6 +137,29 @@ public:
137 137
             size_t encodedWidth, size_t encodedHeight,
138 138
             size_t displayWidth, size_t displayHeight,
139 139
             int32_t rotationDegrees);
  140
+
  141
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  142
+    virtual status_t useBuffer(
  143
+            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
  144
+            buffer_id *buffer, size_t size) = 0;
  145
+#endif
  146
+
  147
+#ifdef OMAP_ENHANCEMENT
  148
+    sp<IOMXRenderer> createRenderer(
  149
+            const sp<Surface> &surface,
  150
+            const char *componentName,
  151
+            OMX_COLOR_FORMATTYPE colorFormat,
  152
+            size_t encodedWidth, size_t encodedHeight,
  153
+            size_t displayWidth, size_t displayHeight, int32_t rotation, int isS3D, int numOfOpBuffers = -1);
  154
+
  155
+        virtual sp<IOMXRenderer> createRenderer(
  156
+            const sp<ISurface> &surface,
  157
+            const char *componentName,
  158
+            OMX_COLOR_FORMATTYPE colorFormat,
  159
+            size_t encodedWidth, size_t encodedHeight,
  160
+            size_t displayWidth, size_t displayHeight, int32_t rotation, int isS3D, int numOfOpBuffers = -1) = 0;
  161
+
  162
+#endif
140 163
 };
141 164
 
142 165
 struct omx_message {
... ...
@@ -144,7 +167,9 @@ struct omx_message {
144 167
         EVENT,
145 168
         EMPTY_BUFFER_DONE,
146 169
         FILL_BUFFER_DONE,
  170
+#ifndef OMAP_ENHANCEMENT
147 171
         REGISTER_BUFFERS
  172
+#endif
148 173
 
149 174
     } type;
150 175
 
... ...
@@ -183,14 +208,27 @@ public:
183 208
     DECLARE_META_INTERFACE(OMXObserver);
184 209
 
185 210
     virtual void onMessage(const omx_message &msg) = 0;
  211
+#ifndef OMAP_ENHANCEMENT
186 212
     virtual void registerBuffers(const sp<IMemoryHeap> &mem) = 0;
  213
+#endif
187 214
 };
188 215
 
  216
+#ifdef OMAP_ENHANCEMENT
  217
+typedef void (*release_rendered_buffer_callback)(const sp<IMemory>& mem, void* cookie);
  218
+#endif
  219
+
189 220
 class IOMXRenderer : public IInterface {
190 221
 public:
191 222
     DECLARE_META_INTERFACE(OMXRenderer);
192 223
 
193 224
     virtual void render(IOMX::buffer_id buffer) = 0;
  225
+#ifdef OMAP_ENHANCEMENT
  226
+    virtual Vector< sp<IMemory> > getBuffers() = 0;
  227
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie) = 0;
  228
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling) =0;
  229
+    virtual void resizeRenderer(void* resize_params) = 0;
  230
+    virtual void requestRendererClone(bool enable) = 0;
  231
+#endif
194 232
 };
195 233
 
196 234
 ////////////////////////////////////////////////////////////////////////////////
Txt include/media/MediaPlayerInterface.h
... ...
@@ -122,7 +122,9 @@ public:
122 122
     virtual player_type playerType() = 0;
123 123
     virtual status_t    suspend() { return INVALID_OPERATION; }
124 124
     virtual status_t    resume() { return INVALID_OPERATION; }
125  
-
  125
+#ifdef OMAP_ENHANCEMENT
  126
+    virtual status_t    requestVideoCloneMode(bool enable) { return INVALID_OPERATION; }
  127
+#endif
126 128
     virtual void        setNotifyCallback(void* cookie, notify_callback_f notifyFunc) {
127 129
                             mCookie = cookie; mNotify = notifyFunc; }
128 130
     // Invoke a generic method on the player by using opaque parcels
Txt include/media/MediaProfiles.h
... ...
@@ -32,6 +32,10 @@ enum camcorder_quality {
32 32
 
33 33
 enum video_decoder {
34 34
     VIDEO_DECODER_WMV,
  35
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  36
+    VIDEO_DECODER_VP6,
  37
+    VIDEO_DECODER_VP7,
  38
+#endif
35 39
 };
36 40
 
37 41
 enum audio_decoder {
Txt include/media/OverlayRenderer.h
... ...
@@ -0,0 +1,127 @@
  1
+/*
  2
+ * Copyright (C) Texas Instruments - http://www.ti.com/
  3
+ *
  4
+ * This library is free software; you can redistribute it and/or
  5
+ * modify it under the terms of the GNU Lesser General Public
  6
+ * License as published by the Free Software Foundation; either
  7
+ * version 2.1 of the License, or (at your option) any later version.
  8
+ *
  9
+ *
  10
+ * This library is distributed in the hope that it will be useful,
  11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13
+ * Lesser General Public License for more details.
  14
+ *
  15
+ *
  16
+ * You should have received a copy of the GNU Lesser General Public
  17
+ * License along with this library; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  19
+ */
  20
+
  21
+#ifndef OVERLAY_RENDERER_H_
  22
+#define OVERLAY_RENDERER_H_
  23
+
  24
+#include <utils/Log.h>
  25
+#include <OMX_Component.h>
  26
+#include <overlay_common.h>
  27
+#include <media/stagefright/MediaDebug.h>
  28
+
  29
+#include <binder/Parcel.h>
  30
+#include <binder/IMemory.h>
  31
+#include <binder/IInterface.h>
  32
+#include <binder/MemoryBase.h>
  33
+#include <binder/MemoryHeapBase.h>
  34
+
  35
+#include <ui/Overlay.h>
  36
+#include <surfaceflinger/Surface.h>
  37
+#include <surfaceflinger/ISurface.h>
  38
+#include <surfaceflinger/ISurfaceComposer.h>
  39
+#include <surfaceflinger/SurfaceComposerClient.h>
  40
+
  41
+namespace android {
  42
+
  43
+class IOverlayRenderer : public IInterface {
  44
+public:
  45
+    DECLARE_META_INTERFACE(OverlayRenderer);
  46
+    virtual int32_t createOverlayRenderer(uint32_t bufferCount,
  47
+                                int32_t displayWidth,
  48
+                                int32_t displayHeight,
  49
+                                uint32_t colorFormat,
  50
+                                int32_t decodedWidth,
  51
+                                int32_t decodedHeight,
  52
+                                int infoType,
  53
+                                void* info)=0;
  54
+
  55
+    virtual void releaseMe()=0;
  56
+    virtual uint32_t getBufferCount()=0;
  57
+    virtual sp<IMemory> getBuffer(uint32_t index) = 0;
  58
+    virtual int32_t dequeueBuffer(uint32_t *index)=0;
  59
+    virtual int32_t queueBuffer(uint32_t index)=0;
  60
+    virtual int32_t setPosition(int32_t x, int32_t y)=0;
  61
+    virtual int32_t setSize(uint32_t w, uint32_t h)=0;
  62
+    virtual int32_t setOrientation(int32_t orientation, uint32_t flags)=0;
  63
+    virtual int32_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)=0;
  64
+};
  65
+
  66
+
  67
+class BnOverlayRenderer : public BnInterface<IOverlayRenderer> {
  68
+public:
  69
+    virtual status_t onTransact(uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags = 0);
  70
+};
  71
+
  72
+
  73
+class OverlayRenderer : public BnOverlayRenderer{
  74
+
  75
+public:
  76
+
  77
+    OverlayRenderer();
  78
+    ~OverlayRenderer();
  79
+    int32_t createOverlayRenderer(uint32_t bufferCount,
  80
+                                int32_t displayWidth,
  81
+                                int32_t displayHeight,
  82
+                                uint32_t colorFormat,
  83
+                                int32_t decodedWidth,
  84
+                                int32_t decodedHeight,
  85
+                                int infoType,
  86
+                                void* info);
  87
+    void releaseMe();
  88
+    uint32_t getBufferCount() { return mBufferCount; }
  89
+    sp<IMemory> getBuffer(uint32_t index);
  90
+    int32_t dequeueBuffer(uint32_t *index);
  91
+    int32_t queueBuffer(uint32_t index);
  92
+    int32_t setPosition(int32_t x, int32_t y) ;
  93
+    int32_t setSize(uint32_t w, uint32_t h) ;
  94
+    int32_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h);
  95
+    int32_t setOrientation(int32_t orientation, uint32_t flags);
  96
+
  97
+private:
  98
+
  99
+    int32_t createSurface();
  100
+    int32_t createBuffers();
  101
+
  102
+    int32_t mInitCheck;
  103
+    int32_t mDisplayWidth, mDisplayHeight;
  104
+    int32_t mDecodedWidth, mDecodedHeight;
  105
+    uint32_t mColorFormat;
  106
+    uint32_t mBufferCount;
  107
+    unsigned int mInfoType;
  108
+
  109
+    /* Surface details */
  110
+    sp<Overlay> mOverlay;
  111
+    sp<SurfaceComposerClient> mSurfaceClient;
  112
+    sp<SurfaceControl> mSurfaceControl;
  113
+    sp<ISurface> mISurface;
  114
+
  115
+    sp<MemoryHeapBase> mVideoHeaps[NUM_OVERLAY_BUFFERS_MAX];
  116
+    Vector< sp<IMemory> > mOverlayAddresses;
  117
+
  118
+    /* copy of previously set window values */
  119
+    int32_t win_x;
  120
+    int32_t win_y;
  121
+
  122
+};
  123
+
  124
+}
  125
+
  126
+#endif
  127
+
Txt include/media/mediaplayer.h
... ...
@@ -175,6 +175,9 @@ public:
175 175
             int             getAudioSessionId();
176 176
             status_t        setAuxEffectSendLevel(float level);
177 177
             status_t        attachAuxEffect(int effectId);
  178
+#ifdef OMAP_ENHANCEMENT
  179
+            status_t        requestVideoCloneMode(bool enable);
  180
+#endif
178 181
 private:
179 182
             void            clear_l();
180 183
             status_t        seekTo_l(int msec);
Txt include/media/mediarecorder.h
... ...
@@ -45,6 +45,10 @@ enum audio_source {
45 45
     AUDIO_SOURCE_CAMCORDER = 5,
46 46
     AUDIO_SOURCE_VOICE_RECOGNITION = 6,
47 47
     AUDIO_SOURCE_VOICE_COMMUNICATION = 7,
  48
+#ifdef OMAP_ENHANCEMENT
  49
+    AUDIO_SOURCE_FM_ANALOG = 8,
  50
+    AUDIO_SOURCE_MAX = AUDIO_SOURCE_FM_ANALOG,
  51
+#else
48 52
 #ifdef HAVE_FM_RADIO
49 53
     AUDIO_SOURCE_FM_RX = 8,
50 54
     AUDIO_SOURCE_FM_RX_A2DP = 9,
... ...
@@ -52,6 +56,7 @@ enum audio_source {
52 56
 #else
53 57
     AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_COMMUNICATION,
54 58
 #endif
  59
+#endif
55 60
     AUDIO_SOURCE_LIST_END  // must be last - used to validate audio source type
56 61
 };
57 62
 
Txt include/media/stagefright/AudioPlayer.h
... ...
@@ -51,7 +51,9 @@ public:
51 51
 
52 52
     void pause(bool playPendingSamples = false);
53 53
     void resume();
54  
-
  54
+#ifdef OMAP_ENHANCEMENT
  55
+    void flush();
  56
+#endif
55 57
     // Returns the timestamp of the last buffer played (in us).
56 58
     int64_t getMediaTimeUs();
57 59
 
... ...
@@ -109,6 +111,10 @@ private:
109 111
 
110 112
     AudioPlayer(const AudioPlayer &);
111 113
     AudioPlayer &operator=(const AudioPlayer &);
  114
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  115
+    int64_t mRealTimeInterpolation;
  116
+    int64_t GetSystemTimeuSec();
  117
+#endif
112 118
 };
113 119
 
114 120
 }  // namespace android
Txt include/media/stagefright/CameraSource.h
... ...
@@ -63,6 +63,9 @@ private:
63 63
     List<sp<IMemory> > mFramesReceived;
64 64
     List<sp<IMemory> > mFramesBeingEncoded;
65 65
     List<int64_t> mFrameTimes;
  66
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  67
+    List<uint32_t> mFrameOffset;
  68
+#endif
66 69
 
67 70
     int64_t mStartTimeUs;
68 71
     int64_t mFirstFrameTimeUs;
... ...
@@ -77,8 +80,14 @@ private:
77 80
 
78 81
     CameraSource(const sp<Camera> &camera);
79 82
 
  83
+#ifdef OMAP_ENHANCEMENT
  84
+    void dataCallbackTimestamp(
  85
+            int64_t timestampUs, int32_t msgType, const sp<IMemory> &data,
  86
+            uint32_t offset=0, uint32_t stride=0);
  87
+#else
80 88
     void dataCallbackTimestamp(
81 89
             int64_t timestampUs, int32_t msgType, const sp<IMemory> &data);
  90
+#endif
82 91
 
83 92
     void releaseQueuedFrames();
84 93
     void releaseOneRecordingFrame(const sp<IMemory>& frame);
Txt include/media/stagefright/ColorConverter.h
... ...
@@ -33,10 +33,18 @@ struct ColorConverter {
33 33
 
34 34
     bool isValid() const;
35 35
 
  36
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  37
+    void convert(
  38
+            size_t width, size_t height,
  39
+            const void *srcBits, size_t srcSkip,
  40
+            void *dstBits, size_t dstSkip,
  41
+            size_t displaywidth=0, size_t displayheight=0,size_t offset=0,bool interlaced=false);
  42
+#else
36 43
     void convert(
37 44
             size_t width, size_t height,
38 45
             const void *srcBits, size_t srcSkip,
39 46
             void *dstBits, size_t dstSkip);
  47
+#endif
40 48
 
41 49
 private:
42 50
     OMX_COLOR_FORMATTYPE mSrcFormat, mDstFormat;
... ...
@@ -83,6 +91,14 @@ private:
83 91
         const uint8_t *blockUV, size_t blockWidth,
84 92
         size_t blockHeight, size_t dstSkip);
85 93
 
  94
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  95
+    void convertYUV420PackedSemiPlanar(
  96
+            size_t width, size_t height,
  97
+            size_t displaywidth, size_t displayheight, size_t offset,
  98
+            const void *srcBits, size_t srcSkip,
  99
+            void *dstBits, size_t dstSkip, bool interlaced);
  100
+#endif
  101
+
86 102
     ColorConverter(const ColorConverter &);
87 103
     ColorConverter &operator=(const ColorConverter &);
88 104
 };
Txt include/media/stagefright/HardwareAPI.h
... ...
@@ -40,6 +40,24 @@ extern android::VideoRenderer *createRendererWithRotation(
40 40
         size_t decodedWidth, size_t decodedHeight,
41 41
         int32_t rotationDegrees);
42 42
 
  43
+#ifdef OMAP_ENHANCEMENT
  44
+extern android::VideoRenderer *createRenderer(
  45
+        const android::sp<android::ISurface> &surface,
  46
+        const char *componentName,
  47
+        OMX_COLOR_FORMATTYPE colorFormat,
  48
+        size_t displayWidth, size_t displayHeight,
  49
+        size_t decodedWidth, size_t decodedHeight,
  50
+        int isS3D, int numOfOpBuffers);
  51
+
  52
+extern android::VideoRenderer *createRendererWithRotation(
  53
+        const android::sp<android::ISurface> &surface,
  54
+        const char *componentName,
  55
+        OMX_COLOR_FORMATTYPE colorFormat,
  56
+        size_t displayWidth, size_t displayHeight,
  57
+        size_t decodedWidth, size_t decodedHeight,
  58
+        int32_t rotationDegrees,
  59
+        int isS3D, int numOfOpBuffers);
  60
+#endif
43 61
 extern android::OMXPluginBase *createOMXPlugin();
44 62
 
45 63
 #endif  // HARDWARE_API_H_
Txt include/media/stagefright/MediaDefs.h
... ...
@@ -27,6 +27,17 @@ extern const char *MEDIA_MIMETYPE_VIDEO_AVC;
27 27
 extern const char *MEDIA_MIMETYPE_VIDEO_MPEG4;
28 28
 extern const char *MEDIA_MIMETYPE_VIDEO_H263;
29 29
 extern const char *MEDIA_MIMETYPE_VIDEO_RAW;
  30
+#if defined(OMAP_ENHANCEMENT)
  31
+#if defined(TARGET_OMAP4)
  32
+extern const char *MEDIA_MIMETYPE_VIDEO_VP6;
  33
+extern const char *MEDIA_MIMETYPE_VIDEO_VP7;
  34
+#endif
  35
+extern const char *MEDIA_MIMETYPE_CONTAINER_ASF;
  36
+extern const char *MEDIA_MIMETYPE_VIDEO_WMV;
  37
+extern const char *MEDIA_MIMETYPE_AUDIO_WMA;
  38
+extern const char *MEDIA_MIMETYPE_AUDIO_WMAPRO;
  39
+extern const char *MEDIA_MIMETYPE_AUDIO_WMALSL;
  40
+#endif
30 41
 
31 42
 extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB;
32 43
 extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB;
... ...
@@ -41,9 +52,13 @@ extern const char *MEDIA_MIMETYPE_AUDIO_RAW;
41 52
 extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4;
42 53
 extern const char *MEDIA_MIMETYPE_CONTAINER_WAV;
43 54
 extern const char *MEDIA_MIMETYPE_CONTAINER_OGG;
  55
+
44 56
 extern const char *MEDIA_MIMETYPE_CONTAINER_MATROSKA;
45 57
 extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG2TS;
46 58
 
  59
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  60
+extern const char *MEDIA_MIMETYPE_CONTAINER_AVI;
  61
+#endif
47 62
 }  // namespace android
48 63
 
49 64
 #endif  // MEDIA_DEFS_H_
Txt include/media/stagefright/MediaErrors.h
... ...
@@ -40,6 +40,9 @@ enum {
40 40
     // Not technically an error.
41 41
     INFO_FORMAT_CHANGED    = MEDIA_ERROR_BASE - 12,
42 42
     INFO_DISCONTINUITY     = MEDIA_ERROR_BASE - 13,
  43
+#ifdef OMAP_ENHANCEMENT
  44
+    ERROR_OUT_OF_MEM       = MEDIA_ERROR_BASE - 14
  45
+#endif
43 46
 };
44 47
 
45 48
 }  // namespace android
Txt include/media/stagefright/MediaExtractor.h
... ...
@@ -17,9 +17,10 @@
17 17
 #ifndef MEDIA_EXTRACTOR_H_
18 18
 
19 19
 #define MEDIA_EXTRACTOR_H_
20  
-
21 20
 #include <utils/RefBase.h>
22 21
 
  22
+#include <utils/String8.h>
  23
+
23 24
 namespace android {
24 25
 
25 26
 class DataSource;
... ...
@@ -33,10 +34,16 @@ public:
33 34
 
34 35
     virtual size_t countTracks() = 0;
35 36
     virtual sp<MediaSource> getTrack(size_t index) = 0;
36  
-
  37
+#ifdef OMAP_ENHANCEMENT
37 38
     enum GetTrackMetaDataFlags {
38  
-        kIncludeExtensiveMetaData = 1
  39
+        kIncludeExtensiveMetaData = 1,
  40
+        kSelectFirstSample = 2
39 41
     };
  42
+#else
  43
+    enum GetTrackMetaDataFlags {
  44
+        kIncludeExtensiveMetaData = 1
  45
+     };
  46
+#endif
40 47
     virtual sp<MetaData> getTrackMetaData(
41 48
             size_t index, uint32_t flags = 0) = 0;
42 49
 
... ...
@@ -64,6 +71,9 @@ private:
64 71
     MediaExtractor &operator=(const MediaExtractor &);
65 72
 };
66 73
 
  74
+bool SniffMPEG4(
  75
+        const sp<DataSource> &source, String8 *mimeType, float *confidence);
  76
+
67 77
 }  // namespace android
68 78
 
69 79
 #endif  // MEDIA_EXTRACTOR_H_
Txt include/media/stagefright/MediaSource.h
... ...
@@ -25,12 +25,20 @@
25 25
 #ifdef USE_GETBUFFERINFO
26 26
 #include <binder/IMemory.h>
27 27
 #endif
  28
+#ifdef OMAP_ENHANCEMENT
  29
+#include <utils/Vector.h>
  30
+#include "binder/IMemory.h"
  31
+#endif
28 32
 
29 33
 namespace android {
30 34
 
31 35
 class MediaBuffer;
32 36
 class MetaData;
33 37
 
  38
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  39
+struct S3D_params;
  40
+#endif
  41
+
34 42
 struct MediaSource : public RefBase {
35 43
     MediaSource();
36 44
 
... ...
@@ -125,6 +133,18 @@ protected:
125 133
 private:
126 134
     MediaSource(const MediaSource &);
127 135
     MediaSource &operator=(const MediaSource &);
  136
+
  137
+public:
  138
+#ifdef OMAP_ENHANCEMENT
  139
+    // Method to share externally allocated buffers with the Codec.
  140
+    virtual void setBuffers(Vector< sp<IMemory> > mBufferAddresse, bool portReconfig = false) {}
  141
+    // Method used to reset read position without consuming the buffer
  142
+    virtual int64_t setSeekTo(const ReadOptions *options) { return 0; }
  143
+    virtual int getNumofOutputBuffers() {return -1; }
  144
+#if defined(TARGET_OMAP4)
  145
+    virtual void parseSEIMessages(S3D_params &mS3Dparams) {}
  146
+#endif
  147
+#endif
128 148
 };
129 149
 
130 150
 }  // namespace android
Txt include/media/stagefright/MetaData.h
... ...
@@ -41,6 +41,10 @@ enum {
41 41
     kKeyBitRate           = 'brte',  // int32_t (bps)
42 42
     kKeyESDS              = 'esds',  // raw data
43 43
     kKeyAVCC              = 'avcc',  // raw data
  44
+#ifdef OMAP_ENHANCEMENT
  45
+    kKeyStreamSpecificData= 'scsd',  // raw data
  46
+    kKeyHdr               = 'hdrd',  // raw data
  47
+#endif
44 48
     kKeyVorbisInfo        = 'vinf',  // raw data
45 49
     kKeyVorbisBooks       = 'vboo',  // raw data
46 50
     kKeyWantsNALFragments = 'NALf',
... ...
@@ -79,6 +83,11 @@ enum {
79 83
     // video profile and level
80 84
     kKeyVideoProfile      = 'vprf',  // int32_t
81 85
     kKeyVideoLevel        = 'vlev',  // int32_t
  86
+#ifdef OMAP_ENHANCEMENT
  87
+    kKeyNumRefFrames      = 'vnrf',  // int32_t
  88
+    kKeyVideoFPS          = 'vfps',  // int32_t
  89
+    kKeyVideoInterlaced   = 'vint',  // int32_t (bool)
  90
+#endif
82 91
 
83 92
     // Set this key to enable authoring files in 64-bit offset
84 93
     kKey64BitFileOffset   = 'fobt',  // int32_t (bool)
... ...
@@ -102,6 +111,16 @@ enum {
102 111
     kKeyValidSamples      = 'valD',  // int32_t
103 112
 
104 113
     kKeyIsUnreadable      = 'unre',  // bool (int32_t)
  114
+
  115
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  116
+    kKeyPaddedWidth       = 'pwid',   // int32_t
  117
+    kKeyPaddedHeight      = 'phei',   // int32_t
  118
+    kKeyOffset            = 'offs',   // int32_t
  119
+    kKeyIsExtraData     = 'xdta',     // int32_t (bool)
  120
+    kKeyS3dSupported     ='s3ds',    // int32_t (bool)
  121
+    kKeySEIEncodingType  ='seit',    // int32_t
  122
+    kKeyFrameLayout      ='frml',    // cstring
  123
+#endif
105 124
 };
106 125
 
107 126
 enum {
Txt include/media/stagefright/OMXCodec.h
... ...
@@ -38,6 +38,13 @@ struct OMXCodec : public MediaSource,
38 38
         // The client wants to access the output buffer's video
39 39
         // data for example for thumbnail extraction.
40 40
         kClientNeedsFramebuffer  = 4,
  41
+#ifdef OMAP_ENHANCEMENT
  42
+        kPreferThumbnailMode               = 0x8,
  43
+        kPreferInterlacedOutputContent     = 0x10,
  44
+        MAX_RESOLUTION = 414720, // video resolution for TI Vid Dec
  45
+        MAX_RESOLUTION_WIDTH = 864, // video width for TI Vid Dec
  46
+        MAX_RESOLUTION_HEIGHT = 864, // video height for TI Vid Dec
  47
+#endif
41 48
     };
42 49
     static sp<MediaSource> Create(
43 50
             const sp<IOMX> &omx,
... ...
@@ -46,6 +53,16 @@ struct OMXCodec : public MediaSource,
46 53
             const char *matchComponentName = NULL,
47 54
             uint32_t flags = 0);
48 55
 
  56
+#ifdef OMAP_ENHANCEMENT
  57
+    static sp<MediaSource> Create(
  58
+            const sp<IOMX> &omx,
  59
+            const sp<MetaData> &meta, bool createEncoder,
  60
+            const sp<MediaSource> &source,
  61
+            IOMX::node_id &nodeId,
  62
+            const char *matchComponentName = NULL,
  63
+            uint32_t flags = 0);
  64
+#endif
  65
+
49 66
     static void setComponentRole(
50 67
             const sp<IOMX> &omx, IOMX::node_id node, bool isEncoder,
51 68
             const char *mime);
... ...
@@ -54,7 +71,10 @@ struct OMXCodec : public MediaSource,
54 71
     virtual status_t stop();
55 72
 
56 73
     virtual sp<MetaData> getFormat();
57  
-
  74
+#ifdef OMAP_ENHANCEMENT
  75
+    virtual void setBuffers(Vector< sp<IMemory> > mBufferAddresses, bool portReconfig = false);
  76
+    virtual int getNumofOutputBuffers();
  77
+#endif
58 78
     virtual status_t read(
59 79
             MediaBuffer **buffer, const ReadOptions *options = NULL);
60 80
 
... ...
@@ -68,7 +88,9 @@ struct OMXCodec : public MediaSource,
68 88
 protected:
69 89
     virtual ~OMXCodec();
70 90
 
  91
+#ifndef OMAP_ENHANCEMENT
71 92
 private:
  93
+#endif
72 94
 
73 95
     // Make sure mLock is accessible to OMXCodecObserver
74 96
     friend class OMXCodecObserver;
... ...
@@ -118,12 +140,21 @@ private:
118 140
         kOutputBuffersAreUnreadable           = 8192,
119 141
         kStoreMetaDataInInputVideoBuffers     = 16384,
120 142
         kCanNotSetVideoParameters             = 32768,
121  
-        kDoesNotRequireMemcpyOnOutputPort     = 65536
  143
+        kDoesNotRequireMemcpyOnOutputPort     = 65536,
  144
+#ifdef OMAP_ENHANCEMENT
  145
+        kDecoderNeedsPortReconfiguration      = 131072,
  146
+        kDecoderCantRenderSmallClips          = 262144,
  147
+        kInterlacedOutputContent              = 524288,
  148
+        kThumbnailMode                        = 1048576,
  149
+#endif
122 150
     };
123 151
 
124 152
     struct BufferInfo {
125 153
         IOMX::buffer_id mBuffer;
126 154
         bool mOwnedByComponent;
  155
+#ifdef OMAP_ENHANCEMENT
  156
+        bool mOwnedByPlayer;
  157
+#endif
127 158
         sp<IMemory> mMem;
128 159
         size_t mSize;
129 160
         void *mData;
... ...
@@ -150,6 +181,11 @@ private:
150 181
     sp<MemoryDealer> mDealer[2];
151 182
 
152 183
     State mState;
  184
+#ifdef OMAP_ENHANCEMENT
  185
+    Vector< sp<IMemory> > mExtBufferAddresses;
  186
+    uint32_t mStride;
  187
+    nsecs_t mNSecsToWait;
  188
+#endif
153 189
     Vector<BufferInfo> mPortBuffers[2];
154 190
     PortStatus mPortStatus[2];
155 191
     bool mInitialBufferSubmit;
... ...
@@ -193,6 +229,11 @@ private:
193 229
     void setVideoInputFormat(
194 230
             const char *mime, const sp<MetaData>& meta);
195 231
 
  232
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  233
+    status_t setupEncoderPresetParams(int32_t isS3DEnabled);
  234
+    status_t setupEncoderFrameDataContentParams(const sp<MetaData>& meta);
  235
+#endif
  236
+
196 237
     status_t setupBitRate(int32_t bitRate);
197 238
     status_t setupErrorCorrectionParameters();
198 239
     status_t setupH263EncoderParameters(const sp<MetaData>& meta);
... ...
@@ -263,11 +304,22 @@ private:
263 304
 
264 305
     void dumpPortStatus(OMX_U32 portIndex);
265 306
 
  307
+#ifdef OMAP_ENHANCEMENT
  308
+public:
  309
+#endif
266 310
     status_t configureCodec(const sp<MetaData> &meta, uint32_t flags);
267 311
 
  312
+#ifdef OMAP_ENHANCEMENT
  313
+protected:
  314
+    static uint32_t getComponentQuirks(const char *componentName, bool isEncoder, uint32_t flags = 0);
  315
+    int32_t mVideoFPS;
  316
+#if defined(TARGET_OMAP4)
  317
+    void setS3DMetaDataConfig(int32_t frameContentType);
  318
+#endif
  319
+#else
268 320
     static uint32_t getComponentQuirks(
269 321
             const char *componentName, bool isEncoder);
270  
-
  322
+#endif
271 323
     static void findMatchingCodecs(
272 324
             const char *mime,
273 325
             bool createEncoder, const char *matchComponentName,
... ...
@@ -276,8 +328,59 @@ private:
276 328
 
277 329
     OMXCodec(const OMXCodec &);
278 330
     OMXCodec &operator=(const OMXCodec &);
  331
+
  332
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4) && defined (NPA_BUFFERS)
  333
+    uint32_t mNumberOfNPABuffersSent;
  334
+  uint32_t mThumbnailEOSSent;
  335
+#endif
279 336
 };
280 337
 
  338
+#if defined(OMAP_ENHANCEMENT)
  339
+struct OMXCodecObserver : public BnOMXObserver {
  340
+    OMXCodecObserver() {
  341
+    }
  342
+
  343
+    void setCodec(const sp<OMXCodec> &target) {
  344
+        mTarget = target;
  345
+    }
  346
+
  347
+    // from IOMXObserver
  348
+    virtual void onMessage(const omx_message &msg) {
  349
+         sp<OMXCodec> codec = mTarget.promote();
  350
+
  351
+        if (codec.get() != NULL) {
  352
+            Mutex::Autolock autoLock(codec->mLock);
  353
+            codec->on_message(msg);
  354
+            codec.clear();
  355
+        }
  356
+    }
  357
+
  358
+protected:
  359
+    virtual ~OMXCodecObserver() {}
  360
+
  361
+private:
  362
+    wp<OMXCodec> mTarget;
  363
+
  364
+    OMXCodecObserver(const OMXCodecObserver &);
  365
+    OMXCodecObserver &operator=(const OMXCodecObserver &);
  366
+};
  367
+
  368
+template<class T>
  369
+static void InitOMXParams(T *params) {
  370
+    params->nSize = sizeof(T);
  371
+    params->nVersion.s.nVersionMajor = 1;
  372
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  373
+    //Ducati strict OMX Version check
  374
+    params->nVersion.s.nVersionMinor = 1;
  375
+#else
  376
+    params->nVersion.s.nVersionMinor = 0;
  377
+#endif
  378
+    params->nVersion.s.nRevision = 0;
  379
+    params->nVersion.s.nStep = 0;
  380
+}
  381
+
  382
+#endif
  383
+
281 384
 struct CodecProfileLevel {
282 385
     OMX_U32 mProfile;
283 386
     OMX_U32 mLevel;
Txt include/media/stagefright/Utils.h
... ...
@@ -19,11 +19,49 @@
19 19
 #define UTILS_H_
20 20
 
21 21
 #include <stdint.h>
  22
+#ifdef OMAP_ENHANCEMENT
  23
+#include <media/stagefright/openmax/OMX_Types.h>
  24
+#include <media/stagefright/openmax/OMX_Index.h>
  25
+#endif
22 26
 
23 27
 namespace android {
24 28
 
25 29
 #define FOURCC(c1, c2, c3, c4) \
26 30
     (c1 << 24 | c2 << 16 | c3 << 8 | c4)
  31
+#ifdef OMAP_ENHANCEMENT
  32
+#ifndef MAKEFOURCC_WMC
  33
+#define MAKEFOURCC_WMC(ch0, ch1, ch2, ch3) \
  34
+        ((OMX_U32)(OMX_U8)(ch0) | ((OMX_U32)(OMX_U8)(ch1) << 8) |   \
  35
+        ((OMX_U32)(OMX_U8)(ch2) << 16) | ((OMX_U32)(OMX_U8)(ch3) << 24 ))
  36
+
  37
+#define mmioFOURCC_WMC(ch0, ch1, ch2, ch3)  MAKEFOURCC_WMC(ch0, ch1, ch2, ch3)
  38
+#endif
  39
+
  40
+#define FOURCC_WMV3     mmioFOURCC_WMC('W','M','V','3')
  41
+#define FOURCC_WMV2     mmioFOURCC_WMC('W','M','V','2')
  42
+#define FOURCC_WMV1     mmioFOURCC_WMC('W','M','V','1')
  43
+#define FOURCC_WMVA     mmioFOURCC_WMC('W','M','V','A')
  44
+#define FOURCC_WVC1     mmioFOURCC_WMC('W','V','C','1')
  45
+
  46
+#define VIDDEC_WMV_ELEMSTREAM                           0
  47
+#define VIDDEC_WMV_RCVSTREAM                            1
  48
+
  49
+typedef enum VIDDEC_CUSTOM_PARAM_INDEX
  50
+{
  51
+    VideoDecodeCustomParamProcessMode = (OMX_IndexVendorStartUnused + 1),
  52
+    VideoDecodeCustomParamH264BitStreamFormat,
  53
+    VideoDecodeCustomParamWMVProfile,
  54
+    VideoDecodeCustomParamWMVFileType,
  55
+    VideoDecodeCustomParamParserEnabled,
  56
+
  57
+} VIDDEC_CUSTOM_PARAM_INDEX;
  58
+
  59
+typedef struct OMX_PARAM_WMVFILETYPE {
  60
+    OMX_U32 nSize;
  61
+    OMX_VERSIONTYPE nVersion;
  62
+    OMX_U32 nWmvFileType;
  63
+} OMX_PARAM_WMVFILETYPE;
  64
+#endif
27 65
 
28 66
 uint16_t U16_AT(const uint8_t *ptr);
29 67
 uint32_t U32_AT(const uint8_t *ptr);
Txt include/media/stagefright/VideoRenderer.h
... ...
@@ -19,9 +19,24 @@
19 19
 #define VIDEO_RENDERER_H_
20 20
 
21 21
 #include <sys/types.h>
  22
+#ifdef OMAP_ENHANCEMENT
  23
+#include "binder/IMemory.h"
  24
+#include <utils/Vector.h>
  25
+#endif
22 26
 
23 27
 namespace android {
24 28
 
  29
+#ifdef OMAP_ENHANCEMENT
  30
+typedef void (*release_rendered_buffer_callback)(const sp<IMemory>& mem, void *cookie);
  31
+typedef struct {
  32
+    uint32_t decoded_width;
  33
+    uint32_t decoded_height;
  34
+    uint32_t buffercount;
  35
+    uint32_t display_width;
  36
+    uint32_t display_height;
  37
+    }render_resize_params;
  38
+#endif
  39
+
25 40
 class VideoRenderer {
26 41
 public:
27 42
     virtual ~VideoRenderer() {}
... ...
@@ -29,6 +44,14 @@ public:
29 44
     virtual void render(
30 45
             const void *data, size_t size, void *platformPrivate) = 0;
31 46
 
  47
+#ifdef OMAP_ENHANCEMENT
  48
+    virtual Vector< sp<IMemory> > getBuffers() = 0;
  49
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie) {return false;}
  50
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling) {}
  51
+    virtual void resizeRenderer(void* resize_params) = 0;
  52
+    virtual void requestRendererClone(bool enable) = 0;
  53
+#endif
  54
+
32 55
 protected:
33 56
     VideoRenderer() {}
34 57
 
Txt include/media/stagefright/openmax/OMX_Index.h
... ...
@@ -58,7 +58,6 @@ extern "C" {
58 58
  */
59 59
 #include <OMX_Types.h>
60 60
 
61  
-
62 61
 /** The OMX_INDEXTYPE enumeration is used to select a structure when either
63 62
  *  getting or setting parameters and/or configuration data.  Each entry in 
64 63
  *  this enumeration maps to an OMX specified structure.  When the 
Txt include/surfaceflinger/ISurface.h
... ...
@@ -48,6 +48,11 @@ protected:
48 48
         CREATE_OVERLAY,
49 49
         REQUEST_BUFFER,
50 50
         SET_BUFFER_COUNT,
  51
+#ifdef OMAP_ENHANCEMENT
  52
+        CREATE_OVERLAY_S3D,
  53
+        SET_DISPLAY_ID,
  54
+        REQUEST_OVERLAY_CLONE
  55
+#endif
51 56
     };
52 57
 
53 58
 public: 
... ...
@@ -109,6 +114,13 @@ public:
109 114
     
110 115
     virtual sp<OverlayRef> createOverlay(
111 116
             uint32_t w, uint32_t h, int32_t format, int32_t orientation) = 0;
  117
+#ifdef OMAP_ENHANCEMENT
  118
+    virtual sp<OverlayRef> createOverlay(
  119
+            uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D) = 0;
  120
+    virtual void setDisplayId(int displayId) = 0;
  121
+    virtual int  requestOverlayClone(bool enable) = 0;
  122
+#endif
  123
+
112 124
 };
113 125
 
114 126
 // ----------------------------------------------------------------------------
Txt include/surfaceflinger/Surface.h
... ...
@@ -79,6 +79,9 @@ public:
79 79
     status_t    setAlpha(float alpha=1.0f);
80 80
     status_t    setMatrix(float dsdx, float dtdx, float dsdy, float dtdy);
81 81
     status_t    setFreezeTint(uint32_t tint);
  82
+#ifdef OMAP_ENHANCEMENT
  83
+    status_t    setDisplayId(int32_t displayId);
  84
+#endif
82 85
 
83 86
     static status_t writeSurfaceToParcel(
84 87
             const sp<SurfaceControl>& control, Parcel* parcel);
... ...
@@ -101,8 +104,9 @@ private:
101 104
     // for testing
102 105
     friend class Test;
103 106
     const sp<ISurface>& getISurface() const { return mSurface; }
104  
-    
105  
-
  107
+#ifdef OMAP_ENHANCEMENT
  108
+    friend class OmapMMLibrary;
  109
+#endif
106 110
     friend class Surface;
107 111
 
108 112
     SurfaceControl(
... ...
@@ -180,7 +184,9 @@ private:
180 184
     friend class IOMX;
181 185
     // this is just to be able to write some unit tests
182 186
     friend class Test;
183  
-
  187
+#ifdef OMAP_ENHANCEMENT
  188
+    friend class OmapMMLibrary;
  189
+#endif
184 190
 private:
185 191
     friend class SurfaceComposerClient;
186 192
     friend class SurfaceControl;
Txt include/ui/FramebufferNativeWindow.h
... ...
@@ -29,8 +29,15 @@
29 29
 
30 30
 #include <ui/egl/android_natives.h>
31 31
 
  32
+#ifdef OMAP_ENHANCEMENT
  33
+/* Define number of buffers */
  34
+#define NUM_FRAME_BUFFERS  2
  35
+#endif
32 36
 
33 37
 extern "C" EGLNativeWindowType android_createDisplaySurface(void);
  38
+#ifdef OMAP_ENHANCEMENT
  39
+extern "C" EGLNativeWindowType android_createDisplaySurfaceOnFB(uint32_t fb_idx);
  40
+#endif
34 41
 
35 42
 // ---------------------------------------------------------------------------
36 43
 namespace android {
... ...
@@ -48,7 +55,11 @@ class FramebufferNativeWindow
48 55
         LightRefBase<FramebufferNativeWindow> >
49 56
 {
50 57
 public:
51  
-    FramebufferNativeWindow(); 
  58
+#ifdef OMAP_ENHANCEMENT
  59
+    FramebufferNativeWindow(uint32_t idx);
  60
+#endif
  61
+    FramebufferNativeWindow();
  62
+
52 63
 
53 64
     framebuffer_device_t const * getDevice() const { return fbDev; } 
54 65
 
... ...
@@ -72,7 +83,11 @@ private:
72 83
     framebuffer_device_t* fbDev;
73 84
     alloc_device_t* grDev;
74 85
 
  86
+#ifdef OMAP_ENHANCEMENT
  87
+    sp<NativeBuffer> buffers[NUM_FRAME_BUFFERS];
  88
+#else
75 89
     sp<NativeBuffer> buffers[2];
  90
+#endif
76 91
     sp<NativeBuffer> front;
77 92
     
78 93
     mutable Mutex mutex;
... ...
@@ -83,7 +98,7 @@ private:
83 98
     int32_t mCurrentBufferIndex;
84 99
     bool mUpdateOnDemand;
85 100
 };
86  
-    
  101
+
87 102
 // ---------------------------------------------------------------------------
88 103
 }; // namespace android
89 104
 // ---------------------------------------------------------------------------
Txt include/ui/Overlay.h
... ...
@@ -88,6 +88,9 @@ public:
88 88
 
89 89
     status_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h) ;
90 90
 
  91
+#ifdef OMAP_ENHANCEMENT
  92
+    status_t set_s3d_params(int32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling);
  93
+#endif
91 94
     status_t getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h) ;
92 95
 
93 96
     /* set the buffer attributes */
Txt libs/camera/Camera.cpp
... ...
@@ -388,7 +388,12 @@ void Camera::dataCallback(int32_t msgType, const sp<IMemory>& dataPtr)
388 388
 }
389 389
 
390 390
 // callback from camera service when timestamped frame is ready
  391
+#ifdef OMAP_ENHANCEMENT
  392
+void Camera::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr,
  393
+        uint32_t offset, uint32_t stride)
  394
+#else
391 395
 void Camera::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr)
  396
+#endif
392 397
 {
393 398
     sp<CameraListener> listener;
394 399
     {
... ...
@@ -396,7 +401,11 @@ void Camera::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<
396 401
         listener = mListener;
397 402
     }
398 403
     if (listener != NULL) {
  404
+#ifdef OMAP_ENHANCEMENT
  405
+        listener->postDataTimestamp(timestamp, msgType, dataPtr, offset, stride);
  406
+#else
399 407
         listener->postDataTimestamp(timestamp, msgType, dataPtr);
  408
+#endif
400 409
     } else {
401 410
         LOGW("No listener was set. Drop a recording frame.");
402 411
         releaseRecordingFrame(dataPtr);
Txt libs/camera/ICameraClient.cpp
... ...
@@ -62,13 +62,22 @@ public:
62 62
     }
63 63
 
64 64
     // generic data callback from camera service to app with image data
  65
+#ifdef OMAP_ENHANCEMENT
  66
+    void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData,
  67
+            uint32_t offset, uint32_t stride)
  68
+#else
65 69
     void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& imageData)
  70
+#endif
66 71
     {
67 72
         LOGV("dataCallback");
68 73
         Parcel data, reply;
69 74
         data.writeInterfaceToken(ICameraClient::getInterfaceDescriptor());
70 75
         data.writeInt64(timestamp);
71 76
         data.writeInt32(msgType);
  77
+#ifdef OMAP_ENHANCEMENT
  78
+        data.writeInt32(offset);
  79
+        data.writeInt32(stride);
  80
+#endif
72 81
         data.writeStrongBinder(imageData->asBinder());
73 82
         remote()->transact(DATA_CALLBACK_TIMESTAMP, data, &reply, IBinder::FLAG_ONEWAY);
74 83
     }
... ...
@@ -104,8 +113,16 @@ status_t BnCameraClient::onTransact(
104 113
             CHECK_INTERFACE(ICameraClient, data, reply);
105 114
             nsecs_t timestamp = data.readInt64();
106 115
             int32_t msgType = data.readInt32();
  116
+#ifdef OMAP_ENHANCEMENT
  117
+            int32_t offset = data.readInt32();
  118
+            int32_t stride = data.readInt32();
  119
+#endif
107 120
             sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder());
  121
+#ifdef OMAP_ENHANCEMENT
  122
+            dataCallbackTimestamp(timestamp, msgType, imageData, offset, stride);
  123
+#else
108 124
             dataCallbackTimestamp(timestamp, msgType, imageData);
  125
+#endif
109 126
             return NO_ERROR;
110 127
         } break;
111 128
         default:
Txt libs/surfaceflinger_client/ISurface.cpp
... ...
@@ -144,6 +144,44 @@ public:
144 144
         remote()->transact(CREATE_OVERLAY, data, &reply);
145 145
         return OverlayRef::readFromParcel(reply);
146 146
     }
  147
+
  148
+#ifdef OMAP_ENHANCEMENT
  149
+   virtual sp<OverlayRef> createOverlay(
  150
+             uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D)
  151
+    {
  152
+        Parcel data, reply;
  153
+        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
  154
+        data.writeInt32(w);
  155
+        data.writeInt32(h);
  156
+        data.writeInt32(format);
  157
+        data.writeInt32(orientation);
  158
+      data.writeInt32(isS3D);
  159
+        remote()->transact(CREATE_OVERLAY_S3D, data, &reply);
  160
+        return OverlayRef::readFromParcel(reply);
  161
+    }
  162
+
  163
+    virtual void setDisplayId(int displayId) {
  164
+        Parcel data, reply;
  165
+        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
  166
+        data.writeInt32(displayId);
  167
+        remote()->transact(SET_DISPLAY_ID, data, &reply);
  168
+        return;
  169
+    }
  170
+
  171
+    virtual int requestOverlayClone(bool enable) {
  172
+        Parcel data, reply;
  173
+        data.writeInterfaceToken(ISurface::getInterfaceDescriptor());
  174
+        data.writeInt32((int)enable);
  175
+        remote()->transact(REQUEST_OVERLAY_CLONE, data, &reply);
  176
+        if (enable) {
  177
+            return (dup(reply.readFileDescriptor()));
  178
+        }
  179
+        else {
  180
+            return -1;
  181
+        }
  182
+    }
  183
+#endif
  184
+
147 185
 };
148 186
 
149 187
 IMPLEMENT_META_INTERFACE(Surface, "android.ui.ISurface");
... ...
@@ -208,6 +246,38 @@ status_t BnSurface::onTransact(
208 246
             sp<OverlayRef> o = createOverlay(w, h, f, orientation);
209 247
             return OverlayRef::writeToParcel(reply, o);
210 248
         } break;
  249
+#ifdef OMAP_ENHANCEMENT
  250
+        case CREATE_OVERLAY_S3D: {
  251
+            CHECK_INTERFACE(ISurface, data, reply);
  252
+            int w = data.readInt32();
  253
+            int h = data.readInt32();
  254
+            int f = data.readInt32();
  255
+            int orientation = data.readInt32();
  256
+          bool isS3D = data.readInt32();
  257
+            sp<OverlayRef> o = createOverlay(w, h, f, orientation, isS3D);
  258
+            return OverlayRef::writeToParcel(reply, o);
  259
+        } break;
  260
+
  261
+        case SET_DISPLAY_ID: {
  262
+            CHECK_INTERFACE(ISurface, data, reply);
  263
+            int dpy = data.readInt32();
  264
+            setDisplayId(dpy);
  265
+            return NO_ERROR;
  266
+        } break;
  267
+
  268
+        case REQUEST_OVERLAY_CLONE: {
  269
+            CHECK_INTERFACE(ISurface, data, reply);
  270
+            int enable = data.readInt32();
  271
+            int fd = requestOverlayClone(enable);
  272
+            if (fd > 0) {
  273
+                return reply->writeFileDescriptor(fd);
  274
+            }
  275
+            else {
  276
+                return reply->writeInt32(fd);
  277
+            }
  278
+        }
  279
+
  280
+#endif
211 281
         default:
212 282
             return BBinder::onTransact(code, data, reply, flags);
213 283
     }
Txt libs/ui/FramebufferNativeWindow.cpp
... ...
@@ -63,7 +63,6 @@ private:
63 63
     ~NativeBuffer() { }; // this class cannot be overloaded
64 64
 };
65 65
 
66  
-
67 66
 /*
68 67
  * This implements the (main) framebuffer management. This class is used
69 68
  * mostly by SurfaceFlinger, but also by command line GL application.
... ...
@@ -71,18 +70,22 @@ private:
71 70
  * In fact this is an implementation of ANativeWindow on top of
72 71
  * the framebuffer.
73 72
  * 
74  
- * Currently it is pretty simple, it manages only two buffers (the front and 
75  
- * back buffer).
76  
- * 
  73
+ * This implementation is able to manage any number of buffers,
  74
+ * defined by NUM_FRAME_BUFFERS (currently set to 2: front
  75
+ * and back buffer)
  76
+ *
77 77
  */
78 78
 
79  
-FramebufferNativeWindow::FramebufferNativeWindow() 
  79
+FramebufferNativeWindow::FramebufferNativeWindow()
80 80
     : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
81 81
 {
82 82
     hw_module_t const* module;
83 83
     if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
84 84
         int stride;
85 85
         int err;
  86
+#ifdef OMAP_ENHANCEMENT
  87
+        int i;
  88
+#endif
86 89
         err = framebuffer_open(module, &fbDev);
87 90
         LOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
88 91
         
... ...
@@ -96,9 +99,36 @@ FramebufferNativeWindow::FramebufferNativeWindow()
96 99
         mUpdateOnDemand = (fbDev->setUpdateRect != 0);
97 100
         
98 101
         // initialize the buffer FIFO
  102
+#ifdef OMAP_ENHANCEMENT
  103
+        mNumBuffers = NUM_FRAME_BUFFERS;
  104
+        mNumFreeBuffers = NUM_FRAME_BUFFERS;
  105
+#else
99 106
         mNumBuffers = 2;
100 107
         mNumFreeBuffers = 2;
  108
+#endif
101 109
         mBufferHead = mNumBuffers-1;
  110
+#ifdef OMAP_ENHANCEMENT
  111
+        for(i = 0; i < NUM_FRAME_BUFFERS; i++){
  112
+            buffers[i] = new NativeBuffer(
  113
+                    fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);
  114
+        }
  115
+
  116
+        for(i = 0; i < NUM_FRAME_BUFFERS; i++){
  117
+            err = grDev->alloc(grDev,
  118
+                    fbDev->width, fbDev->height, fbDev->format,
  119
+                    GRALLOC_USAGE_HW_FB, &buffers[i]->handle, &buffers[i]->stride);
  120
+
  121
+            LOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
  122
+                    i, fbDev->width, fbDev->height, strerror(-err));
  123
+
  124
+            if(err){
  125
+                mNumBuffers = i;
  126
+                mNumFreeBuffers = i;
  127
+                mBufferHead = mNumBuffers-1;
  128
+                break;
  129
+            }
  130
+       }
  131
+#else
102 132
         buffers[0] = new NativeBuffer(
103 133
                 fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB);
104 134
         buffers[1] = new NativeBuffer(
... ...
@@ -117,7 +147,7 @@ FramebufferNativeWindow::FramebufferNativeWindow()
117 147
 
118 148
         LOGE_IF(err, "fb buffer 1 allocation failed w=%d, h=%d, err=%s",
119 149
                 fbDev->width, fbDev->height, strerror(-err));
120  
-
  150
+#endif
121 151
         const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags; 
122 152
         const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
123 153
         const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
... ...
@@ -136,10 +166,99 @@ FramebufferNativeWindow::FramebufferNativeWindow()
136 166
     ANativeWindow::cancelBuffer = NULL;
137 167
     ANativeWindow::query = query;
138 168
     ANativeWindow::perform = perform;
  169
+    ANativeWindow::cancelBuffer = 0;
  170
+#ifdef OMAP_ENHANCEMENT
  171
+    LOGE("%d buffers flip-chain implementation enabled\n", mNumBuffers);
  172
+#endif
139 173
 }
140 174
 
  175
+#ifdef OMAP_ENHANCEMENT
  176
+FramebufferNativeWindow::FramebufferNativeWindow(uint32_t idx)
  177
+    : BASE(), fbDev(0), grDev(0), mUpdateOnDemand(false)
  178
+{
  179
+    hw_module_t const* module;
  180
+
  181
+    if (hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module) == 0) {
  182
+        int stride;
  183
+        int err;
  184
+        int i;
  185
+        const size_t SIZE = 16;
  186
+        char fbname[SIZE];
  187
+        snprintf(fbname, SIZE, "fb%u", idx);
  188
+
  189
+        err = framebuffer_open_by_name(module, &fbDev, fbname);
  190
+        LOGE_IF(err, "couldn't open framebuffer HAL (%s)", strerror(-err));
  191
+
  192
+        err = gralloc_open(module, &grDev);
  193
+        LOGE_IF(err, "couldn't open gralloc HAL (%s)", strerror(-err));
  194
+
  195
+        // bail out if we can't initialize the modules
  196
+        if (!fbDev || !grDev)
  197
+            return;
  198
+
  199
+        mUpdateOnDemand = (fbDev->setUpdateRect != 0);
  200
+
  201
+        // initialize the buffer FIFO
  202
+        mNumBuffers = NUM_FRAME_BUFFERS;
  203
+        mNumFreeBuffers = NUM_FRAME_BUFFERS;
  204
+        mBufferHead = mNumBuffers-1;
  205
+
  206
+        for(i = 0; i < NUM_FRAME_BUFFERS; i++){
  207
+            buffers[i] = new NativeBuffer(
  208
+                    fbDev->width, fbDev->height, fbDev->format, GRALLOC_USAGE_HW_FB << idx);
  209
+        }
  210
+
  211
+        for(i = 0; i < NUM_FRAME_BUFFERS; i++){
  212
+            err = grDev->alloc(grDev,
  213
+                    fbDev->width, fbDev->height, fbDev->format,
  214
+                    GRALLOC_USAGE_HW_FB << idx, &buffers[i]->handle, &buffers[i]->stride);
  215
+
  216
+            LOGE_IF(err, "fb buffer %d allocation failed w=%d, h=%d, err=%s",
  217
+                    i, fbDev->width, fbDev->height, strerror(-err));
  218
+
  219
+            if(err){
  220
+                mNumBuffers = i;
  221
+                mNumFreeBuffers = i;
  222
+                mBufferHead = mNumBuffers-1;
  223
+                break;
  224
+            }
  225
+       }
  226
+
  227
+        const_cast<uint32_t&>(ANativeWindow::flags) = fbDev->flags;
  228
+        const_cast<float&>(ANativeWindow::xdpi) = fbDev->xdpi;
  229
+        const_cast<float&>(ANativeWindow::ydpi) = fbDev->ydpi;
  230
+        const_cast<int&>(ANativeWindow::minSwapInterval) =
  231
+            fbDev->minSwapInterval;
  232
+        const_cast<int&>(ANativeWindow::maxSwapInterval) =
  233
+            fbDev->maxSwapInterval;
  234
+    } else {
  235
+        LOGE("Couldn't get gralloc module");
  236
+    }
  237
+
  238
+    ANativeWindow::setSwapInterval = setSwapInterval;
  239
+    ANativeWindow::dequeueBuffer = dequeueBuffer;
  240
+    ANativeWindow::lockBuffer = lockBuffer;
  241
+    ANativeWindow::queueBuffer = queueBuffer;
  242
+    ANativeWindow::query = query;
  243
+    ANativeWindow::perform = perform;
  244
+
  245
+    LOGE("%d buffers flip-chain implementation enabled\n", mNumBuffers);
  246
+}
  247
+#endif
  248
+
141 249
 FramebufferNativeWindow::~FramebufferNativeWindow() 
142 250
 {
  251
+#ifdef OMAP_ENHANCEMENT
  252
+    int i;
  253
+
  254
+   if (grDev){
  255
+        for (i = 0; i < mNumBuffers; i++){
  256
+            if (buffers[i] != NULL)
  257
+                grDev->free(grDev, buffers[i]->handle);
  258
+        }
  259
+        gralloc_close(grDev);
  260
+    }
  261
+#else
143 262
     if (grDev) {
144 263
         if (buffers[0] != NULL)
145 264
             grDev->free(grDev, buffers[0]->handle);
... ...
@@ -147,7 +266,7 @@ FramebufferNativeWindow::~FramebufferNativeWindow()
147 266
             grDev->free(grDev, buffers[1]->handle);
148 267
         gralloc_close(grDev);
149 268
     }
150  
-
  269
+#endif
151 270
     if (fbDev) {
152 271
         framebuffer_close(fbDev);
153 272
     }
... ...
@@ -295,6 +414,20 @@ int FramebufferNativeWindow::perform(ANativeWindow* window,
295 414
 
296 415
 using namespace android;
297 416
 
  417
+#ifdef OMAP_ENHANCEMENT
  418
+EGLNativeWindowType android_createDisplaySurfaceOnFB(uint32_t fb_idx)
  419
+{
  420
+    FramebufferNativeWindow* w;
  421
+    w = new FramebufferNativeWindow(fb_idx);
  422
+    if (w->getDevice() == NULL) {
  423
+        // get a ref so it can be destroyed when we exit this block
  424
+        sp<FramebufferNativeWindow> ref(w);
  425
+        return NULL;
  426
+    }
  427
+    return (EGLNativeWindowType)w;
  428
+}
  429
+#endif
  430
+
298 431
 EGLNativeWindowType android_createDisplaySurface(void)
299 432
 {
300 433
     FramebufferNativeWindow* w;
Txt libs/ui/Overlay.cpp
... ...
@@ -78,6 +78,14 @@ status_t Overlay::setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
78 78
     return mOverlayData->setCrop(mOverlayData, x, y, w, h);
79 79
 }
80 80
 
  81
+#ifdef OMAP_ENHANCEMENT
  82
+status_t Overlay::set_s3d_params(int32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling)
  83
+{
  84
+    if (mStatus != NO_ERROR) return mStatus;
  85
+    return mOverlayData->set_s3d_params(mOverlayData, s3d_mode, s3d_fmt, s3d_order, s3d_subsampling);
  86
+}
  87
+#endif
  88
+
81 89
 status_t Overlay::getCrop(uint32_t* x, uint32_t* y, uint32_t* w, uint32_t* h)
82 90
 {
83 91
     if (mStatus != NO_ERROR) return mStatus;
Txt media/java/android/media/AudioService.java
... ...
@@ -120,6 +120,15 @@ public class AudioService extends IAudioService.Stub {
120 120
     private int mMode;
121 121
     private Object mSettingsLock = new Object();
122 122
     private boolean mMediaServerOk;
  123
+    /*
  124
+     * OMAP4 specific intents that the AudioService
  125
+     * will register to recieve
  126
+     */
  127
+    private static final String ACTION_FM_PLUG = "android.intent.action.FM_PLUG";
  128
+    private static final String ACTION_FMTX_PLUG = "android.intent.action.FMTX_PLUG";
  129
+    private static final String POWER_MODE = "omap.audio.power";
  130
+    private static final String MAIN_MIC_CHOICE = "omap.audio.mic.main";
  131
+    private static final String SUB_MIC_CHOICE = "omap.audio.mic.sub";
123 132
 
124 133
     private SoundPool mSoundPool;
125 134
     private Object mSoundEffectsLock = new Object();
... ...
@@ -305,6 +314,14 @@ public class AudioService extends IAudioService.Stub {
305 314
         // Register for device connection intent broadcasts.
306 315
         IntentFilter intentFilter =
307 316
                 new IntentFilter(Intent.ACTION_HEADSET_PLUG);
  317
+        if (SystemProperties.OMAP_ENHANCEMENT) {
  318
+            intentFilter.addAction(ACTION_FM_PLUG);
  319
+            intentFilter.addAction(ACTION_FMTX_PLUG);
  320
+            intentFilter.addAction(POWER_MODE);
  321
+            intentFilter.addAction(MAIN_MIC_CHOICE);
  322
+            intentFilter.addAction(SUB_MIC_CHOICE);
  323
+        }
  324
+
308 325
         intentFilter.addAction(BluetoothA2dp.ACTION_SINK_STATE_CHANGED);
309 326
         intentFilter.addAction(BluetoothHeadset.ACTION_STATE_CHANGED);
310 327
         intentFilter.addAction(Intent.ACTION_DOCK_EVENT);
... ...
@@ -1981,6 +1998,80 @@ public class AudioService extends IAudioService.Stub {
1981 1998
                         }
1982 1999
                     }
1983 2000
                 }
  2001
+           } else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(ACTION_FM_PLUG)) {
  2002
+               int state = intent.getIntExtra("state",0);
  2003
+
  2004
+               boolean isConnected = mConnectedDevices.containsKey(AudioSystem.DEVICE_IN_FM_ANALOG );
  2005
+               if (state == 0 && isConnected) {
  2006
+                      Log.v(TAG,"calling FM Rx Analog  Off");
  2007
+                      AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_FM_ANALOG ,
  2008
+                               AudioSystem.DEVICE_STATE_UNAVAILABLE,"");
  2009
+                      mConnectedDevices.remove(AudioSystem.DEVICE_IN_FM_ANALOG );
  2010
+               } else if (state == 1 && !isConnected)  {
  2011
+                      Log.v(TAG,"calling FM Rx Analog On");
  2012
+                      AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_FM_ANALOG ,
  2013
+                                AudioSystem.DEVICE_STATE_AVAILABLE,"");
  2014
+                      mConnectedDevices.put( new Integer(AudioSystem.DEVICE_IN_FM_ANALOG ), "");
  2015
+               }
  2016
+           } else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(ACTION_FMTX_PLUG)) {
  2017
+               int state = intent.getIntExtra("state",0);
  2018
+
  2019
+               boolean isConnected = mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_FM_TRANSMIT );
  2020
+               if (state == 0 && isConnected) {
  2021
+                      Log.e(TAG,"calling FM Transmit Off");
  2022
+                      AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM_TRANSMIT ,
  2023
+                               AudioSystem.DEVICE_STATE_UNAVAILABLE,"");
  2024
+                      mConnectedDevices.remove(AudioSystem.DEVICE_OUT_FM_TRANSMIT );
  2025
+               } else if (state == 1 && !isConnected)  {
  2026
+                      Log.e(TAG,"calling FM Transmit On");
  2027
+                      AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_FM_TRANSMIT ,
  2028
+                                AudioSystem.DEVICE_STATE_AVAILABLE,"");
  2029
+                      mConnectedDevices.put( new Integer(AudioSystem.DEVICE_OUT_FM_TRANSMIT ), "");
  2030
+               }
  2031
+            } else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(POWER_MODE)) {
  2032
+                Intent noisyIntent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
  2033
+                mContext.sendBroadcast(noisyIntent);
  2034
+                boolean isConnected = mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_WIRED_HEADSET) |
  2035
+                                      mConnectedDevices.containsKey(AudioSystem.DEVICE_OUT_WIRED_HEADPHONE);
  2036
+                if (intent.getBooleanExtra("LP", false) && isConnected) {
  2037
+                    // enable low power mode
  2038
+                    AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_LOW_POWER ,
  2039
+                                                         AudioSystem.DEVICE_STATE_AVAILABLE,"");
  2040
+                    mConnectedDevices.put(new Integer(AudioSystem.DEVICE_OUT_LOW_POWER), "");
  2041
+                    Log.e(TAG,"Action: power mode is now LP, re-routing");
  2042
+                }
  2043
+                else {
  2044
+                    Log.e(TAG,"Action: power mode is now HQ, re-routing");
  2045
+                    AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_LOW_POWER ,
  2046
+                                                         AudioSystem.DEVICE_STATE_UNAVAILABLE,"");
  2047
+                    mConnectedDevices.remove(AudioSystem.DEVICE_OUT_LOW_POWER);
  2048
+                }
  2049
+            } else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(MAIN_MIC_CHOICE)) {
  2050
+                /*
  2051
+                 * mic choice is not configurable by intent yet, this is here for future use.
  2052
+                 * eventually, the mic choice will be set from applications using this intent
  2053
+                 * and we will update the logic to be flexible for mics other than DMIC0.
  2054
+                 */
  2055
+                Intent noisyIntent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
  2056
+                mContext.sendBroadcast(noisyIntent);
  2057
+                if (intent.getBooleanExtra("DMic0L", true)) {
  2058
+                     Log.e(TAG,"MAIN MIC - DMIC0L selected");
  2059
+                } else if (intent.getBooleanExtra("AMic0", true)) {
  2060
+                    Log.e(TAG,"MAIN MIC - AMIC selected");
  2061
+                } else {
  2062
+                    Log.e(TAG,"MAIN MIC - invalid selection, only [DMIC0L,AMIC0] supported");
  2063
+                }
  2064
+            } else if (SystemProperties.OMAP_ENHANCEMENT && action.equals(SUB_MIC_CHOICE)) {
  2065
+                // mic choice is not configurable by intent yet, this is here for future use
  2066
+                Intent noisyIntent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
  2067
+                mContext.sendBroadcast(noisyIntent);
  2068
+                if (intent.getBooleanExtra("DMic0R", true)) {
  2069
+                    Log.e(TAG,"SUB MIC - DMIC0R selected");
  2070
+                } else if (intent.getBooleanExtra("AMic1", true)) {
  2071
+                    Log.e(TAG,"SUB MIC - AMIC selected");
  2072
+                } else {
  2073
+                    Log.e(TAG,"SUB MIC - invalid selection, only [DMIC0R,AMIC] supported");
  2074
+                }
1984 2075
             }
1985 2076
         }
1986 2077
     }
Txt media/java/android/media/AudioSystem.java
... ...
@@ -260,6 +260,10 @@ public class AudioSystem
260 260
     public static final int DEVICe_IN_FM_RX = 0x1000000;
261 261
     public static final int DEVICe_IN_FM_RXA2DP = 0x2000000;
262 262
     public static final int DEVICE_IN_DEFAULT = 0x80000000;
  263
+    // For OMAP
  264
+    public static final int DEVICE_OUT_FM_TRANSMIT = 0x800;
  265
+    public static final int DEVICE_IN_FM_ANALOG = 0x1000000;
  266
+    public static final int DEVICE_OUT_LOW_POWER = 0x1000;
263 267
 
264 268
     // device states
265 269
     public static final int DEVICE_STATE_UNAVAILABLE = 0;
Txt media/java/android/media/DecoderCapabilities.java
... ...
@@ -33,6 +33,8 @@ public class DecoderCapabilities
33 33
      */
34 34
     public enum VideoDecoder {
35 35
         VIDEO_DECODER_WMV,
  36
+        VIDEO_DECODER_VP6,
  37
+        VIDEO_DECODER_VP7,
36 38
     };
37 39
 
38 40
     /**
Txt media/java/android/media/MediaFile.java
... ...
@@ -23,6 +23,7 @@ import android.provider.MediaStore.Video;
23 23
 import android.media.DecoderCapabilities;
24 24
 import android.media.DecoderCapabilities.VideoDecoder;
25 25
 import android.media.DecoderCapabilities.AudioDecoder;
  26
+import android.os.SystemProperties;
26 27
 
27 28
 import java.util.HashMap;
28 29
 import java.util.Iterator;
... ...
@@ -57,7 +58,7 @@ public class MediaFile {
57 58
     public static final int FILE_TYPE_IMY     = 13;
58 59
     private static final int FIRST_MIDI_FILE_TYPE = FILE_TYPE_MID;
59 60
     private static final int LAST_MIDI_FILE_TYPE = FILE_TYPE_IMY;
60  
-   
  61
+
61 62
     // Video file types
62 63
     public static final int FILE_TYPE_MP4     = 21;
63 64
     public static final int FILE_TYPE_M4V     = 22;
... ...
@@ -65,42 +66,49 @@ public class MediaFile {
65 66
     public static final int FILE_TYPE_3GPP2   = 24;
66 67
     public static final int FILE_TYPE_WMV     = 25;
67 68
     public static final int FILE_TYPE_ASF     = 26;
  69
+
68 70
     public static final int FILE_TYPE_MKV     = 27;
69 71
     public static final int FILE_TYPE_MP2TS   = 28;
70 72
     private static final int FIRST_VIDEO_FILE_TYPE = FILE_TYPE_MP4;
71  
-    private static final int LAST_VIDEO_FILE_TYPE = FILE_TYPE_MP2TS;
72  
-    
  73
+
  74
+    public static final int FILE_TYPE_AVI     = 29;
  75
+    private static final int LAST_VIDEO_FILE_TYPE = FILE_TYPE_AVI;
  76
+
73 77
     // Image file types
74 78
     public static final int FILE_TYPE_JPEG    = 31;
75 79
     public static final int FILE_TYPE_GIF     = 32;
76 80
     public static final int FILE_TYPE_PNG     = 33;
77 81
     public static final int FILE_TYPE_BMP     = 34;
78 82
     public static final int FILE_TYPE_WBMP    = 35;
  83
+    public static final int FILE_TYPE_JPS    = 36;
  84
+    public static final int FILE_TYPE_MPO    = 37;
  85
+
79 86
     private static final int FIRST_IMAGE_FILE_TYPE = FILE_TYPE_JPEG;
80 87
     private static final int LAST_IMAGE_FILE_TYPE = FILE_TYPE_WBMP;
81  
-   
  88
+    private static final int LAST_IMAGE_FILE_TYPE_S3D = FILE_TYPE_MPO;
  89
+
82 90
     // Playlist file types
83 91
     public static final int FILE_TYPE_M3U     = 41;
84 92
     public static final int FILE_TYPE_PLS     = 42;
85 93
     public static final int FILE_TYPE_WPL     = 43;
86 94
     private static final int FIRST_PLAYLIST_FILE_TYPE = FILE_TYPE_M3U;
87 95
     private static final int LAST_PLAYLIST_FILE_TYPE = FILE_TYPE_WPL;
88  
-    
  96
+
89 97
     static class MediaFileType {
90  
-    
  98
+
91 99
         int fileType;
92 100
         String mimeType;
93  
-        
  101
+
94 102
         MediaFileType(int fileType, String mimeType) {
95 103
             this.fileType = fileType;
96 104
             this.mimeType = mimeType;
97 105
         }
98 106
     }
99  
-    
100  
-    private static HashMap<String, MediaFileType> sFileTypeMap 
  107
+
  108
+    private static HashMap<String, MediaFileType> sFileTypeMap
101 109
             = new HashMap<String, MediaFileType>();
102  
-    private static HashMap<String, Integer> sMimeTypeMap 
103  
-            = new HashMap<String, Integer>();            
  110
+    private static HashMap<String, Integer> sMimeTypeMap
  111
+            = new HashMap<String, Integer>();
104 112
     static void addFileType(String extension, int fileType, String mimeType) {
105 113
         sFileTypeMap.put(extension, new MediaFileType(fileType, mimeType));
106 114
         sMimeTypeMap.put(mimeType, Integer.valueOf(fileType));
... ...
@@ -149,7 +157,7 @@ public class MediaFile {
149 157
         addFileType("IMY", FILE_TYPE_IMY, "audio/imelody");
150 158
         addFileType("RTX", FILE_TYPE_MID, "audio/midi");
151 159
         addFileType("OTA", FILE_TYPE_MID, "audio/midi");
152  
-        
  160
+
153 161
         addFileType("MPEG", FILE_TYPE_MP4, "video/mpeg");
154 162
         addFileType("MP4", FILE_TYPE_MP4, "video/mp4");
155 163
         addFileType("M4V", FILE_TYPE_M4V, "video/mp4");
... ...
@@ -165,14 +173,22 @@ public class MediaFile {
165 173
             addFileType("WMV", FILE_TYPE_WMV, "video/x-ms-wmv");
166 174
             addFileType("ASF", FILE_TYPE_ASF, "video/x-ms-asf");
167 175
         }
168  
-
  176
+        if("true".equals(System.getProperty("omap.enhancement"))) {
  177
+            addFileType("AVI", FILE_TYPE_AVI, "video/avi");
  178
+        }
169 179
         addFileType("JPG", FILE_TYPE_JPEG, "image/jpeg");
170 180
         addFileType("JPEG", FILE_TYPE_JPEG, "image/jpeg");
171 181
         addFileType("GIF", FILE_TYPE_GIF, "image/gif");
172 182
         addFileType("PNG", FILE_TYPE_PNG, "image/png");
173 183
         addFileType("BMP", FILE_TYPE_BMP, "image/x-ms-bmp");
174 184
         addFileType("WBMP", FILE_TYPE_WBMP, "image/vnd.wap.wbmp");
175  
  185
+
  186
+        if(SystemProperties.OMAP_ENHANCEMENT)
  187
+        {
  188
+        addFileType("JPS", FILE_TYPE_JPS, "image/jps");
  189
+        addFileType("MPO", FILE_TYPE_MPO, "image/mpo");
  190
+       }
  191
+
176 192
         addFileType("M3U", FILE_TYPE_M3U, "audio/x-mpegurl");
177 193
         addFileType("PLS", FILE_TYPE_PLS, "audio/x-scpls");
178 194
         addFileType("WPL", FILE_TYPE_WPL, "application/vnd.ms-wpl");
... ...
@@ -180,45 +196,52 @@ public class MediaFile {
180 196
         // compute file extensions list for native Media Scanner
181 197
         StringBuilder builder = new StringBuilder();
182 198
         Iterator<String> iterator = sFileTypeMap.keySet().iterator();
183  
-        
  199
+
184 200
         while (iterator.hasNext()) {
185 201
             if (builder.length() > 0) {
186 202
                 builder.append(',');
187 203
             }
188 204
             builder.append(iterator.next());
189  
-        } 
  205
+        }
190 206
         sFileExtensions = builder.toString();
191 207
     }
192  
-    
  208
+
193 209
     public static boolean isAudioFileType(int fileType) {
194 210
         return ((fileType >= FIRST_AUDIO_FILE_TYPE &&
195 211
                 fileType <= LAST_AUDIO_FILE_TYPE) ||
196 212
                 (fileType >= FIRST_MIDI_FILE_TYPE &&
197 213
                 fileType <= LAST_MIDI_FILE_TYPE));
198 214
     }
199  
-    
  215
+
200 216
     public static boolean isVideoFileType(int fileType) {
201 217
         return (fileType >= FIRST_VIDEO_FILE_TYPE &&
202 218
                 fileType <= LAST_VIDEO_FILE_TYPE);
203 219
     }
204  
-    
  220
+
205 221
     public static boolean isImageFileType(int fileType) {
  222
+    if(SystemProperties.OMAP_ENHANCEMENT)
  223
+        {
  224
+            return (fileType >= FIRST_IMAGE_FILE_TYPE &&
  225
+                    fileType <= LAST_IMAGE_FILE_TYPE_S3D);
  226
+        }
  227
+    else
  228
+        {
206 229
         return (fileType >= FIRST_IMAGE_FILE_TYPE &&
207 230
                 fileType <= LAST_IMAGE_FILE_TYPE);
  231
+        }
208 232
     }
209  
-    
  233
+
210 234
     public static boolean isPlayListFileType(int fileType) {
211 235
         return (fileType >= FIRST_PLAYLIST_FILE_TYPE &&
212 236
                 fileType <= LAST_PLAYLIST_FILE_TYPE);
213 237
     }
214  
-    
  238
+
215 239
     public static MediaFileType getFileType(String path) {
216 240
         int lastDot = path.lastIndexOf(".");
217 241
         if (lastDot < 0)
218 242
             return null;
219 243
         return sFileTypeMap.get(path.substring(lastDot + 1).toUpperCase());
220 244
     }
221  
-    
222 245
     public static int getFileTypeForMimeType(String mimeType) {
223 246
         Integer value = sMimeTypeMap.get(mimeType);
224 247
         return (value == null ? 0 : value.intValue());
Txt media/java/android/media/MediaRecorder.java
... ...
@@ -28,6 +28,7 @@ import java.io.FileNotFoundException;
28 28
 import java.io.FileOutputStream;
29 29
 import java.io.FileDescriptor;
30 30
 import java.lang.ref.WeakReference;
  31
+import android.os.SystemProperties;
31 32
 
32 33
 /**
33 34
  * Used to record audio and video. The recording control is based on a
... ...
@@ -302,11 +303,24 @@ public class MediaRecorder
302 303
         setVideoFrameRate(profile.videoFrameRate);
303 304
         setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
304 305
         setVideoEncodingBitRate(profile.videoBitRate);
305  
-        setAudioEncodingBitRate(profile.audioBitRate);
306  
-        setAudioChannels(profile.audioChannels);
307  
-        setAudioSamplingRate(profile.audioSampleRate);
308  
-        setVideoEncoder(profile.videoCodec);
309  
-        setAudioEncoder(profile.audioCodec);
  306
+
  307
+        if(SystemProperties.OMAP_ENHANCEMENT) {
  308
+            setVideoEncoder(profile.videoCodec);
  309
+
  310
+            if (profile.audioCodec != 0)
  311
+            {
  312
+                setAudioEncodingBitRate(profile.audioBitRate);
  313
+                setAudioChannels(profile.audioChannels);
  314
+                setAudioSamplingRate(profile.audioSampleRate);
  315
+                setAudioEncoder(profile.audioCodec);
  316
+            }
  317
+        } else {
  318
+            setAudioEncodingBitRate(profile.audioBitRate);
  319
+            setAudioChannels(profile.audioChannels);
  320
+            setAudioSamplingRate(profile.audioSampleRate);
  321
+            setVideoEncoder(profile.videoCodec);
  322
+            setAudioEncoder(profile.audioCodec);
  323
+        }
310 324
     }
311 325
 
312 326
     /**
Txt media/java/android/media/MediaScanner.java
... ...
@@ -45,6 +45,7 @@ import android.text.TextUtils;
45 45
 import android.util.Config;
46 46
 import android.util.Log;
47 47
 import android.util.Xml;
  48
+import android.os.SystemProperties;
48 49
 
49 50
 import java.io.BufferedReader;
50 51
 import java.io.File;
... ...
@@ -735,7 +736,9 @@ public class MediaScanner
735 736
                 values.put(Audio.Media.IS_ALARM, alarms);
736 737
                 values.put(Audio.Media.IS_MUSIC, music);
737 738
                 values.put(Audio.Media.IS_PODCAST, podcasts);
738  
-            } else if (mFileType == MediaFile.FILE_TYPE_JPEG) {
  739
+            } else if ((mFileType == MediaFile.FILE_TYPE_JPEG) ||
  740
+                       ((SystemProperties.OMAP_ENHANCEMENT) && (mFileType == MediaFile.FILE_TYPE_JPS)) ||
  741
+                       ((SystemProperties.OMAP_ENHANCEMENT) && (mFileType == MediaFile.FILE_TYPE_MPO))) {
739 742
                 ExifInterface exif = null;
740 743
                 try {
741 744
                     exif = new ExifInterface(entry.mPath);
Txt media/java/android/media/ThumbnailUtils.java
... ...
@@ -33,6 +33,7 @@ import android.provider.BaseColumns;
33 33
 import android.provider.MediaStore.Images;
34 34
 import android.provider.MediaStore.Images.Thumbnails;
35 35
 import android.util.Log;
  36
+import android.os.SystemProperties;
36 37
 
37 38
 import java.io.FileInputStream;
38 39
 import java.io.FileDescriptor;
... ...
@@ -98,7 +99,9 @@ public class ThumbnailUtils {
98 99
         SizedThumbnailBitmap sizedThumbnailBitmap = new SizedThumbnailBitmap();
99 100
         Bitmap bitmap = null;
100 101
         MediaFileType fileType = MediaFile.getFileType(filePath);
101  
-        if (fileType != null && fileType.fileType == MediaFile.FILE_TYPE_JPEG) {
  102
+        if (fileType != null && ((fileType.fileType == MediaFile.FILE_TYPE_JPEG) ||
  103
+                                 ((SystemProperties.OMAP_ENHANCEMENT) && (fileType.fileType == MediaFile.FILE_TYPE_JPS)) ||
  104
+                                 ((SystemProperties.OMAP_ENHANCEMENT)&& (fileType.fileType == MediaFile.FILE_TYPE_MPO)))){
102 105
             createThumbnailFromEXIF(filePath, targetSize, maxPixels, sizedThumbnailBitmap);
103 106
             bitmap = sizedThumbnailBitmap.mBitmap;
104 107
         }
Txt media/libmedia/Android.mk
... ...
@@ -58,4 +58,12 @@ LOCAL_C_INCLUDES := \
58 58
     external/icu4c/common \
59 59
     external/expat/lib
60 60
 
  61
+ifeq ($(OMAP_ENHANCEMENT),true)
  62
+
  63
+LOCAL_SRC_FILES += OverlayRenderer.cpp
  64
+
  65
+LOCAL_C_INCLUDES += $(TOP)/hardware/ti/omap3/liboverlay
  66
+
  67
+endif
  68
+
61 69
 include $(BUILD_SHARED_LIBRARY)
Txt media/libmedia/IAudioFlinger.cpp
... ...
@@ -71,7 +71,11 @@ enum {
71 71
     GET_EFFECT_DESCRIPTOR,
72 72
     CREATE_EFFECT,
73 73
     MOVE_EFFECTS,
  74
+#ifdef OMAP_ENHANCEMENT
  75
+    SET_FMRX_ACTIVE
  76
+#else
74 77
     SET_FM_VOLUME
  78
+#endif
75 79
 };
76 80
 
77 81
 class BpAudioFlinger : public BpInterface<IAudioFlinger>
... ...
@@ -271,7 +275,16 @@ public:
271 275
         remote()->transact(SET_STREAM_MUTE, data, &reply);
272 276
         return reply.readInt32();
273 277
     }
274  
-
  278
+#ifdef OMAP_ENHANCEMENT
  279
+    virtual status_t setFMRxActive( bool state)
  280
+    {
  281
+        Parcel data, reply;
  282
+        data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
  283
+        data.writeInt32(state);
  284
+        remote()->transact(SET_FMRX_ACTIVE, data, &reply);
  285
+        return reply.readInt32();
  286
+    }
  287
+#endif
275 288
     virtual float streamVolume(int stream, int output) const
276 289
     {
277 290
         Parcel data, reply;
... ...
@@ -808,6 +821,13 @@ status_t BnAudioFlinger::onTransact(
808 821
             reply->writeInt32( setStreamMute(stream, data.readInt32()) );
809 822
             return NO_ERROR;
810 823
         } break;
  824
+#ifdef OMAP_ENHANCEMENT
  825
+        case SET_FMRX_ACTIVE: {
  826
+            CHECK_INTERFACE(IAudioFlinger, data, reply);
  827
+            reply->writeInt32( setFMRxActive(data.readInt32()) );
  828
+            return NO_ERROR;
  829
+        } break;
  830
+#endif
811 831
         case STREAM_VOLUME: {
812 832
             CHECK_INTERFACE(IAudioFlinger, data, reply);
813 833
             int stream = data.readInt32();
Txt media/libmedia/IMediaPlayer.cpp
... ...
@@ -46,7 +46,10 @@ enum {
46 46
     SUSPEND,
47 47
     RESUME,
48 48
     SET_AUX_EFFECT_SEND_LEVEL,
49  
-    ATTACH_AUX_EFFECT
  49
+    ATTACH_AUX_EFFECT,
  50
+#ifdef OMAP_ENHANCEMENT
  51
+    REQUEST_CLONE_MODE
  52
+#endif
50 53
 };
51 54
 
52 55
 class BpMediaPlayer: public BpInterface<IMediaPlayer>
... ...
@@ -241,6 +244,17 @@ public:
241 244
         remote()->transact(ATTACH_AUX_EFFECT, data, &reply);
242 245
         return reply.readInt32();
243 246
     }
  247
+
  248
+#ifdef OMAP_ENHANCEMENT
  249
+    status_t requestVideoCloneMode(bool enable) {
  250
+        Parcel data, reply;
  251
+        data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
  252
+        data.writeInt32((int)enable);
  253
+        remote()->transact(REQUEST_CLONE_MODE, data, &reply);
  254
+        return reply.readInt32();
  255
+    }
  256
+
  257
+#endif
244 258
 };
245 259
 
246 260
 IMPLEMENT_META_INTERFACE(MediaPlayer, "android.media.IMediaPlayer");
... ...
@@ -369,6 +383,13 @@ status_t BnMediaPlayer::onTransact(
369 383
             reply->writeInt32(attachAuxEffect(data.readInt32()));
370 384
             return NO_ERROR;
371 385
         } break;
  386
+#ifdef OMAP_ENHANCEMENT
  387
+        case REQUEST_CLONE_MODE: {
  388
+            CHECK_INTERFACE(IMediaPlayer, data, reply);
  389
+            reply->writeInt32(requestVideoCloneMode(data.readInt32()));
  390
+            return NO_ERROR;
  391
+        } break;
  392
+#endif
372 393
         default:
373 394
             return BBinder::onTransact(code, data, reply, flags);
374 395
     }
Txt media/libmedia/IMediaPlayerService.cpp
... ...
@@ -23,9 +23,12 @@
23 23
 #include <media/IMediaPlayerService.h>
24 24
 #include <media/IMediaRecorder.h>
25 25
 #include <media/IOMX.h>
26  
-
27 26
 #include <utils/Errors.h>  // for status_t
28 27
 
  28
+#ifdef OMAP_ENHANCEMENT
  29
+#include <media/OverlayRenderer.h>
  30
+#endif
  31
+
29 32
 namespace android {
30 33
 
31 34
 enum {
... ...
@@ -35,7 +38,10 @@ enum {
35 38
     DECODE_FD,
36 39
     CREATE_MEDIA_RECORDER,
37 40
     CREATE_METADATA_RETRIEVER,
38  
-    GET_OMX
  41
+    GET_OMX,
  42
+#ifdef OMAP_ENHANCEMENT
  43
+    GET_OVERLAY_RENDERER,
  44
+#endif
39 45
 };
40 46
 
41 47
 class BpMediaPlayerService: public BpInterface<IMediaPlayerService>
... ...
@@ -139,6 +145,15 @@ public:
139 145
         remote()->transact(GET_OMX, data, &reply);
140 146
         return interface_cast<IOMX>(reply.readStrongBinder());
141 147
     }
  148
+
  149
+#ifdef OMAP_ENHANCEMENT
  150
+    virtual sp<IOverlayRenderer> getOverlayRenderer() {
  151
+        Parcel data, reply;
  152
+        data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
  153
+        remote()->transact(GET_OVERLAY_RENDERER, data, &reply);
  154
+        return interface_cast<IOverlayRenderer>(reply.readStrongBinder());
  155
+    }
  156
+#endif
142 157
 };
143 158
 
144 159
 IMPLEMENT_META_INTERFACE(MediaPlayerService, "android.media.IMediaPlayerService");
... ...
@@ -232,6 +247,14 @@ status_t BnMediaPlayerService::onTransact(
232 247
             reply->writeStrongBinder(omx->asBinder());
233 248
             return NO_ERROR;
234 249
         } break;
  250
+#ifdef OMAP_ENHANCEMENT
  251
+        case GET_OVERLAY_RENDERER: {
  252
+            CHECK_INTERFACE(IMediaPlayerService, data, reply);
  253
+            sp<IOverlayRenderer> renderer = getOverlayRenderer();
  254
+            reply->writeStrongBinder(renderer->asBinder());
  255
+            return NO_ERROR;
  256
+        } break;
  257
+#endif
235 258
         default:
236 259
             return BBinder::onTransact(code, data, reply, flags);
237 260
     }
Txt media/libmedia/IOMX.cpp
... ...
@@ -29,9 +29,15 @@ enum {
29 29
     EMPTY_BUFFER,
30 30
     GET_EXTENSION_INDEX,
31 31
     CREATE_RENDERER,
  32
+#ifdef OMAP_ENHANCEMENT
  33
+    CREATE_RENDERER_S3D,
  34
+#endif
32 35
     OBSERVER_ON_MSG,
33 36
     RENDERER_RENDER,
34  
-    REGISTER_BUFFERS
  37
+    REGISTER_BUFFERS,
  38
+#ifdef OMAP_ENHANCEMENT
  39
+    GET_BUFFERS,
  40
+#endif
35 41
 };
36 42
 
37 43
 sp<IOMXRenderer> IOMX::createRenderer(
... ...
@@ -48,6 +54,20 @@ sp<IOMXRenderer> IOMX::createRenderer(
48 54
             rotationDegrees);
49 55
 }
50 56
 
  57
+#ifdef OMAP_ENHANCEMENT
  58
+sp<IOMXRenderer> IOMX::createRenderer(
  59
+        const sp<Surface> &surface,
  60
+        const char *componentName,
  61
+        OMX_COLOR_FORMATTYPE colorFormat,
  62
+        size_t encodedWidth, size_t encodedHeight,
  63
+        size_t displayWidth, size_t displayHeight, int32_t rotate, int isS3D, int numOfOpBuffers) {
  64
+    return createRenderer(
  65
+            surface->getISurface(),
  66
+            componentName, colorFormat, encodedWidth, encodedHeight,
  67
+            displayWidth, displayHeight, rotate, isS3D, numOfOpBuffers);
  68
+}
  69
+#endif
  70
+
51 71
 sp<IOMXRenderer> IOMX::createRendererFromJavaSurface(
52 72
         JNIEnv *env, jobject javaSurface,
53 73
         const char *componentName,
... ...
@@ -221,14 +241,31 @@ public:
221 241
         return reply.readInt32();
222 242
     }
223 243
 
  244
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
224 245
     virtual status_t useBuffer(
225 246
             node_id node, OMX_U32 port_index, const sp<IMemory> &params,
226 247
             buffer_id *buffer) {
  248
+        return useBuffer(node, port_index, params, buffer, 0);
  249
+    }
  250
+#endif
  251
+
  252
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  253
+    virtual status_t useBuffer(
  254
+            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
  255
+            buffer_id *buffer, size_t size) {
  256
+#else
  257
+    virtual status_t useBuffer(
  258
+            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
  259
+            buffer_id *buffer) {
  260
+#endif
227 261
         Parcel data, reply;
228 262
         data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
229 263
         data.writeIntPtr((intptr_t)node);
230 264
         data.writeInt32(port_index);
231 265
         data.writeStrongBinder(params->asBinder());
  266
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  267
+        data.writeInt32(size);
  268
+#endif
232 269
         remote()->transact(USE_BUFFER, data, &reply);
233 270
 
234 271
         status_t err = reply.readInt32();
... ...
@@ -372,6 +409,33 @@ public:
372 409
 
373 410
         return interface_cast<IOMXRenderer>(reply.readStrongBinder());
374 411
     }
  412
+
  413
+#ifdef OMAP_ENHANCEMENT
  414
+    virtual sp<IOMXRenderer> createRenderer(
  415
+            const sp<ISurface> &surface,
  416
+            const char *componentName,
  417
+            OMX_COLOR_FORMATTYPE colorFormat,
  418
+            size_t encodedWidth, size_t encodedHeight,
  419
+            size_t displayWidth, size_t displayHeight, int32_t rotationDegrees, int isS3D, int numOfOpBuffers) {
  420
+        Parcel data, reply;
  421
+        data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
  422
+        data.writeStrongBinder(surface->asBinder());
  423
+        data.writeCString(componentName);
  424
+        data.writeInt32(colorFormat);
  425
+        data.writeInt32(encodedWidth);
  426
+        data.writeInt32(encodedHeight);
  427
+        data.writeInt32(displayWidth);
  428
+        data.writeInt32(displayHeight);
  429
+        data.writeInt32(rotationDegrees);
  430
+  data.writeInt32(isS3D);
  431
+        data.writeInt32(numOfOpBuffers);
  432
+
  433
+        remote()->transact(CREATE_RENDERER_S3D, data, &reply);
  434
+
  435
+        return interface_cast<IOMXRenderer>(reply.readStrongBinder());
  436
+    }
  437
+#endif
  438
+
375 439
 };
376 440
 
377 441
 IMPLEMENT_META_INTERFACE(OMX, "android.hardware.IOMX");
... ...
@@ -558,7 +622,12 @@ status_t BnOMX::onTransact(
558 622
                 interface_cast<IMemory>(data.readStrongBinder());
559 623
 
560 624
             buffer_id buffer;
  625
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  626
+            OMX_U32 size = data.readInt32();
  627
+            status_t err = useBuffer(node, port_index, params, &buffer, size);
  628
+#else
561 629
             status_t err = useBuffer(node, port_index, params, &buffer);
  630
+#endif
562 631
             reply->writeInt32(err);
563 632
 
564 633
             if (err == OK) {
... ...
@@ -702,6 +771,37 @@ status_t BnOMX::onTransact(
702 771
             return OK;
703 772
         }
704 773
 
  774
+#ifdef OMAP_ENHANCEMENT
  775
+  case CREATE_RENDERER_S3D:
  776
+        {
  777
+            CHECK_INTERFACE(IOMX, data, reply);
  778
+
  779
+            sp<ISurface> isurface =
  780
+                interface_cast<ISurface>(data.readStrongBinder());
  781
+
  782
+            const char *componentName = data.readCString();
  783
+
  784
+            OMX_COLOR_FORMATTYPE colorFormat =
  785
+                static_cast<OMX_COLOR_FORMATTYPE>(data.readInt32());
  786
+
  787
+            size_t encodedWidth = (size_t)data.readInt32();
  788
+            size_t encodedHeight = (size_t)data.readInt32();
  789
+            size_t displayWidth = (size_t)data.readInt32();
  790
+            size_t displayHeight = (size_t)data.readInt32();
  791
+            int32_t rotationDegrees = data.readInt32();
  792
+            size_t isS3D = (size_t)data.readInt32();
  793
+            int numOfOpBuffers = (int)data.readInt32();
  794
+
  795
+            sp<IOMXRenderer> renderer =
  796
+                createRenderer(isurface, componentName, colorFormat,
  797
+                               encodedWidth, encodedHeight,
  798
+                               displayWidth, displayHeight, rotationDegrees, isS3D, numOfOpBuffers);
  799
+            reply->writeStrongBinder(renderer->asBinder());
  800
+
  801
+            return OK;
  802
+        }
  803
+#endif
  804
+
705 805
         default:
706 806
             return BBinder::onTransact(code, data, reply, flags);
707 807
     }
... ...
@@ -748,6 +848,7 @@ status_t BnOMXObserver::onTransact(
748 848
 
749 849
             return NO_ERROR;
750 850
         }
  851
+#ifndef OMAP_ENHANCEMENT
751 852
         case REGISTER_BUFFERS:
752 853
         {
753 854
             CHECK_INTERFACE(IOMXObserver, data, reply);
... ...
@@ -755,6 +856,7 @@ status_t BnOMXObserver::onTransact(
755 856
                interface_cast<IMemoryHeap>(data.readStrongBinder());
756 857
             registerBuffers(mem);
757 858
         }
  859
+#endif
758 860
 
759 861
         default:
760 862
             return BBinder::onTransact(code, data, reply, flags);
... ...
@@ -778,6 +880,30 @@ public:
778 880
         // so that the caller knows when to recycle the buffer.
779 881
         remote()->transact(RENDERER_RENDER, data, &reply);
780 882
     }
  883
+
  884
+#ifdef OMAP_ENHANCEMENT
  885
+    virtual Vector< sp<IMemory> > getBuffers(){
  886
+        int n = 0;
  887
+        Vector< sp<IMemory> > mMem;
  888
+        Parcel data, reply;
  889
+        data.writeInterfaceToken(IOMXRenderer::getInterfaceDescriptor());
  890
+
  891
+        status_t err = remote()->transact(GET_BUFFERS, data, &reply);
  892
+        n = reply.readInt32();
  893
+        for (int i=0;i < n; i++) {
  894
+            sp<IMemory> mem = interface_cast<IMemory>(reply.readStrongBinder());
  895
+            mMem.add(mem);
  896
+        }
  897
+        return mMem;
  898
+    }
  899
+
  900
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie) {return false;}
  901
+
  902
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling) {}
  903
+    virtual void resizeRenderer(void* resize_params) {}
  904
+    virtual void requestRendererClone(bool enable) {}
  905
+#endif
  906
+
781 907
 };
782 908
 
783 909
 IMPLEMENT_META_INTERFACE(OMXRenderer, "android.hardware.IOMXRenderer");
... ...
@@ -796,6 +922,20 @@ status_t BnOMXRenderer::onTransact(
796 922
             return NO_ERROR;
797 923
         }
798 924
 
  925
+#ifdef OMAP_ENHANCEMENT
  926
+        case GET_BUFFERS:
  927
+        {
  928
+            LOGV("<<<<< onTransact GET_BUFFERS");
  929
+            CHECK_INTERFACE(IOMXRenderer, data, reply);
  930
+            Vector< sp<IMemory> > mMem = getBuffers();
  931
+            const size_t N = mMem.size();
  932
+            reply->writeInt32(N);
  933
+            for (size_t i=0; i<N; i++) {
  934
+                reply->writeStrongBinder(mMem[i]->asBinder());
  935
+            }
  936
+            return NO_ERROR;
  937
+        }
  938
+#endif
799 939
         default:
800 940
             return BBinder::onTransact(code, data, reply, flags);
801 941
     }
Txt media/libmedia/MediaProfiles.cpp
... ...
@@ -52,6 +52,10 @@ const MediaProfiles::NameToTagMap MediaProfiles::sFileFormatMap[] = {
52 52
 
53 53
 const MediaProfiles::NameToTagMap MediaProfiles::sVideoDecoderNameMap[] = {
54 54
     {"wmv", VIDEO_DECODER_WMV}
  55
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  56
+    , {"vp6", VIDEO_DECODER_VP6}
  57
+    , {"vp7", VIDEO_DECODER_VP7}
  58
+#endif
55 59
 };
56 60
 
57 61
 const MediaProfiles::NameToTagMap MediaProfiles::sAudioDecoderNameMap[] = {
Txt media/libmedia/OverlayRenderer.cpp
... ...
@@ -0,0 +1,608 @@
  1
+/*
  2
+ * Copyright (C) Texas Instruments - http://www.ti.com/
  3
+ *
  4
+ * This library is free software; you can redistribute it and/or
  5
+ * modify it under the terms of the GNU Lesser General Public
  6
+ * License as published by the Free Software Foundation; either
  7
+ * version 2.1 of the License, or (at your option) any later version.
  8
+ *
  9
+ *
  10
+ * This library is distributed in the hope that it will be useful,
  11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13
+ * Lesser General Public License for more details.
  14
+ *
  15
+ *
  16
+ * You should have received a copy of the GNU Lesser General Public
  17
+ * License along with this library; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  19
+ */
  20
+
  21
+//#define LOG_NDEBUG 0
  22
+#define LOG_TAG "OverlayRenderer"
  23
+#include <media/OverlayRenderer.h>
  24
+
  25
+#define ARMPAGESIZE 4096
  26
+#define BOOL_STR(val)  ( (val) ? "TRUE" : "FALSE")
  27
+
  28
+#define LOG_FUNCTION_NAME_ENTRY    LOGV(" ###### Calling %s() Line %d PID %d ++ ######",  __FUNCTION__, __LINE__, getpid());
  29
+#define LOG_FUNCTION_NAME_EXIT    LOGV(" ###### Calling %s() -- ######",  __FUNCTION__);
  30
+
  31
+//#define __DUMP_TO_FILE__
  32
+#ifdef __DUMP_TO_FILE__
  33
+#define NUM_BUFFERS_TO_DUMP 46
  34
+#define FIRST_FRAME_INDEX 23
  35
+FILE *pOutFile;
  36
+#endif
  37
+
  38
+using namespace android;
  39
+
  40
+namespace android{
  41
+
  42
+/*
  43
+  * Test is a friend class of Surface Control, and hence has access
  44
+  * getISurface() method.
  45
+  * TODO: The test class is 'added' by TI as a friend. Need to add
  46
+  * TIFlashRenderer as a 'friend' to get the ISurface.
  47
+  */
  48
+class Test {
  49
+        public:
  50
+            static const sp<ISurface>& getISurface(const sp<SurfaceControl>& s) {
  51
+                return s->getISurface();
  52
+            }
  53
+    };
  54
+
  55
+#ifdef __DUMP_TO_FILE__
  56
+
  57
+void dumpBufferToFile(void* pSrc, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t s)
  58
+{
  59
+    //LOGD("framenumber = %u, pSrc = %p, x = %u, y = %u, w = %u, h = %u, s = %u", framenumber, pSrc, x, y, w, h, s);
  60
+    /* Dumping only the Y component */
  61
+    pSrc = pSrc + (y*s);
  62
+    for (int i = 0; i < h; i++) {
  63
+        fwrite(pSrc+x, 1, w, pOutFile);
  64
+        fflush(pOutFile);
  65
+        pSrc = pSrc + s;
  66
+    }
  67
+}
  68
+
  69
+#endif
  70
+
  71
+OverlayRenderer::OverlayRenderer()
  72
+{
  73
+    LOG_FUNCTION_NAME_ENTRY
  74
+}
  75
+
  76
+OverlayRenderer::~OverlayRenderer()
  77
+{
  78
+    LOG_FUNCTION_NAME_ENTRY
  79
+}
  80
+
  81
+int32_t OverlayRenderer::createOverlayRenderer(uint32_t bufferCount,
  82
+                                int32_t displayWidth,
  83
+                                int32_t displayHeight,
  84
+                                uint32_t colorFormat,
  85
+                                int32_t decodedWidth,
  86
+                                int32_t decodedHeight,
  87
+                                int infoType,
  88
+                                void * info)
  89
+{
  90
+    LOG_FUNCTION_NAME_ENTRY
  91
+
  92
+    mBufferCount = bufferCount;
  93
+    mDisplayWidth = displayWidth;
  94
+    mDisplayHeight = displayHeight;
  95
+    mColorFormat = colorFormat;
  96
+    mDecodedWidth = decodedWidth;
  97
+    mDecodedHeight = decodedHeight;
  98
+    mInfoType = infoType;
  99
+    //Keep in mind that info ptr is NOT passed across in BpOverlayRenderer
  100
+
  101
+    mInitCheck = NO_INIT;
  102
+
  103
+    /* Create required surfaces and overlay objects */
  104
+    if(OK != createSurface()){
  105
+        LOGE("Failed to create Surface");
  106
+        goto EXIT;
  107
+    }
  108
+
  109
+    /* creating buffers */
  110
+    if(OK != createBuffers()) {
  111
+        LOGE("Failed to create Buffers");
  112
+        goto EXIT;
  113
+    }
  114
+
  115
+    mInitCheck = OK;
  116
+
  117
+#ifdef __DUMP_TO_FILE__
  118
+
  119
+    char filename[100];
  120
+    sprintf(filename, "/sdcard/framedump_%dx%d.yuv", mDisplayWidth, mDisplayHeight);
  121
+    pOutFile = fopen(filename, "wb");
  122
+    if(pOutFile == NULL)
  123
+        LOGE("\n!!!!!!!!!!!!!!!!Error opening file %s !!!!!!!!!!!!!!!!!!!!", filename);
  124
+
  125
+#endif
  126
+
  127
+EXIT:
  128
+
  129
+    return mInitCheck;
  130
+}
  131
+
  132
+void OverlayRenderer::releaseMe()
  133
+{
  134
+    //delete this;
  135
+
  136
+    LOG_FUNCTION_NAME_ENTRY
  137
+
  138
+    if ( NULL != mOverlay.get() ) {
  139
+        mOverlay->destroy();
  140
+        mOverlay.clear();
  141
+    }
  142
+
  143
+    //if ( NULL != mOverlayRef.get() )
  144
+    {
  145
+        //mOverlayRef = 0;
  146
+    }
  147
+
  148
+    if ( NULL != mISurface.get() ) {
  149
+        mISurface.clear();
  150
+    }
  151
+
  152
+    if ( NULL != mSurfaceControl.get() ) {
  153
+        mSurfaceControl->clear();
  154
+        mSurfaceControl.clear();
  155
+    }
  156
+
  157
+    if ( NULL != mSurfaceClient.get() ) {
  158
+        mSurfaceClient->dispose();
  159
+        mSurfaceClient.clear();
  160
+    }
  161
+
  162
+
  163
+    /* TODO: make sure all other resources are released as well */
  164
+
  165
+#ifdef __DUMP_TO_FILE__
  166
+        if (pOutFile) fclose(pOutFile);
  167
+#endif
  168
+
  169
+}
  170
+
  171
+sp<IMemory> OverlayRenderer::getBuffer(uint32_t index)
  172
+{
  173
+    if (index >= mBufferCount) index = 0;
  174
+    return mOverlayAddresses[index];
  175
+}
  176
+
  177
+int32_t OverlayRenderer::createBuffers()
  178
+{
  179
+    LOG_FUNCTION_NAME_ENTRY
  180
+
  181
+    mapping_data_t *data;
  182
+    sp<IMemory> mem;
  183
+
  184
+    /* check if the overlay created required number of buffers for decoder */
  185
+    if (mBufferCount != (uint32_t)mOverlay->getBufferCount() ) {
  186
+        mOverlay->setParameter(OVERLAY_NUM_BUFFERS, mBufferCount);
  187
+        mOverlay->resizeInput(mDecodedWidth, mDecodedHeight);
  188
+    }
  189
+
  190
+    /* TODO: Optimal buffer count now 2. Confirm?? */
  191
+    mOverlay->setParameter(OPTIMAL_QBUF_CNT, 4);
  192
+
  193
+    for (size_t bCount = 0; bCount < mBufferCount; ++bCount) {
  194
+        data = (mapping_data_t *)mOverlay->getBufferAddress((void *)bCount);
  195
+        CHECK(data != NULL);
  196
+
  197
+        mVideoHeaps[bCount] = new MemoryHeapBase(data->fd,data->length, 0, data->offset);
  198
+        mem = new MemoryBase(mVideoHeaps[bCount], 0, data->length);
  199
+        CHECK(mem.get() != NULL);
  200
+
  201
+        LOGV("data->fd %d, data->length =%d, data->offset =%x, mem->pointer[%d] = %p", data->fd,data->length, data->offset, bCount, mem->pointer());
  202
+
  203
+        mOverlayAddresses.push(mem);
  204
+    }
  205
+
  206
+    return OK;
  207
+}
  208
+
  209
+
  210
+int32_t OverlayRenderer::createSurface()
  211
+{
  212
+    LOG_FUNCTION_NAME_ENTRY
  213
+
  214
+    if(mOverlay.get() == NULL){
  215
+
  216
+        mSurfaceClient = new SurfaceComposerClient();
  217
+
  218
+        if ( NULL == mSurfaceClient.get() ) {
  219
+            LOGE("Unable to establish connection to Surface Composer \n");
  220
+            return UNKNOWN_ERROR;
  221
+        }
  222
+
  223
+        mSurfaceControl = mSurfaceClient->createSurface(getpid(), 0, mDecodedWidth, mDecodedHeight,
  224
+                           PIXEL_FORMAT_UNKNOWN, ISurfaceComposer::ePushBuffers);
  225
+
  226
+        if ( NULL == mSurfaceControl.get() ) {
  227
+            LOGE("Unable to create Overlay control surface\n");
  228
+            return UNKNOWN_ERROR;
  229
+        }
  230
+
  231
+        mISurface = Test::getISurface(mSurfaceControl);
  232
+        if ( NULL == mISurface.get() ) {
  233
+            LOGE("Unable to get overlay ISurface interface\n");
  234
+            return UNKNOWN_ERROR;
  235
+        }
  236
+
  237
+        sp<OverlayRef> ref = mISurface->createOverlay(mDecodedWidth, mDecodedHeight, mColorFormat, 0);
  238
+        if (ref.get() == NULL) {
  239
+            LOGE("Unable to create Overlay Reference\n");
  240
+            return UNKNOWN_ERROR;
  241
+        }
  242
+
  243
+        //Create Overlay Object
  244
+        mOverlay = new Overlay(ref);
  245
+
  246
+        if(mOverlay.get() == NULL) {
  247
+            LOGE("Unable to create Overlay Object\n");
  248
+            return UNKNOWN_ERROR;
  249
+        }
  250
+
  251
+        /* Configuring the surface */
  252
+        mSurfaceClient->openTransaction();
  253
+        mSurfaceControl->setLayer(100000);
  254
+        //mSurfaceControl->setLayer(0x40000000);set in BootAnimation.cpp
  255
+        mSurfaceClient->closeTransaction();
  256
+
  257
+    }
  258
+    return OK;
  259
+
  260
+}
  261
+
  262
+int32_t OverlayRenderer::dequeueBuffer(uint32_t *index)
  263
+{
  264
+    return mOverlay->dequeueBuffer((overlay_buffer_t*)index);
  265
+}
  266
+
  267
+int32_t OverlayRenderer::queueBuffer(uint32_t index)
  268
+{
  269
+
  270
+#ifdef __DUMP_TO_FILE__
  271
+    static int displaycount = 0;
  272
+    static int lastframetodump = FIRST_FRAME_INDEX+NUM_BUFFERS_TO_DUMP;
  273
+
  274
+    if ((displaycount >= FIRST_FRAME_INDEX)  && (displaycount < lastframetodump)){
  275
+        //dumpBufferToFile(mediaBuf->data(), mCropX, mCropY, mDisplayWidth, mDisplayHeight, 4096);
  276
+    }
  277
+    displaycount++;
  278
+
  279
+#endif
  280
+
  281
+    return mOverlay->queueBuffer((void *)index);
  282
+}
  283
+
  284
+int32_t OverlayRenderer::setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
  285
+{
  286
+    return mOverlay->setCrop(x, y, w, h);
  287
+}
  288
+
  289
+int32_t OverlayRenderer::setPosition(int32_t x, int32_t y)
  290
+{
  291
+    win_x = x;
  292
+    win_y = y;
  293
+    mSurfaceClient->openTransaction();
  294
+    mSurfaceControl->setPosition(win_x, win_y);
  295
+    mSurfaceClient->closeTransaction();
  296
+
  297
+    return OK;
  298
+}
  299
+
  300
+int32_t OverlayRenderer::setSize(uint32_t w, uint32_t h)
  301
+{
  302
+    mSurfaceClient->openTransaction();
  303
+    mSurfaceControl->setSize(w, h);
  304
+    mSurfaceClient->closeTransaction();
  305
+
  306
+    /* I am changing Position too bcos just a change in size is not recognized by surface flinger. */
  307
+
  308
+    /* In LayerBase::setPosition(), the sequence no. is incremented. But the same is not done
  309
+        for LayerBase::setSize(). It is this change in sequence no. which triggers
  310
+        LayerBuffer::OverlaySource::onTransaction() which triggers
  311
+        LayerBuffer::OverlaySource::onVisibilityResolved() which triggers
  312
+        overlay_dev->setPosition()
  313
+    */
  314
+
  315
+    mSurfaceClient->openTransaction();
  316
+    mSurfaceControl->setPosition(1, 1);
  317
+    mSurfaceClient->closeTransaction();
  318
+
  319
+    mSurfaceClient->openTransaction();
  320
+    mSurfaceControl->setPosition(win_x, win_y);
  321
+    mSurfaceClient->closeTransaction();
  322
+
  323
+    return OK;
  324
+}
  325
+
  326
+int32_t OverlayRenderer::setOrientation(int32_t orientation, uint32_t flags)
  327
+{
  328
+    mSurfaceClient->openTransaction();
  329
+    switch(orientation)
  330
+        {
  331
+        case 0:
  332
+            mSurfaceClient->setOrientation(0,ISurfaceComposer::eOrientationDefault,0);
  333
+            break;
  334
+        case 90:
  335
+            mSurfaceClient->setOrientation(0,ISurfaceComposer::eOrientation90,0);
  336
+            break;
  337
+        case 180:
  338
+            mSurfaceClient->setOrientation(0,ISurfaceComposer::eOrientation180,0);
  339
+            break;
  340
+        case 270:
  341
+            mSurfaceClient->setOrientation(0,ISurfaceComposer::eOrientation270,0);
  342
+            break;
  343
+        default:
  344
+            LOGD("Rotation not applied. Illegal Value");
  345
+        };
  346
+
  347
+    mSurfaceClient->closeTransaction();
  348
+    return OK;
  349
+}
  350
+
  351
+////////////////////////////////////////////////////////////////////////////////
  352
+
  353
+enum {
  354
+    CREATE_OVERLAY_RENDERER,
  355
+    RELEASE,
  356
+    GET_BUFFER_COUNT,
  357
+    GET_BUFFER,
  358
+    DEQUEUE_BUFFER,
  359
+    QUEUE_BUFFER,
  360
+    SET_ORIENTATION,
  361
+    SET_POSITION,
  362
+    SET_SIZE,
  363
+    SET_CROP
  364
+};
  365
+
  366
+
  367
+
  368
+class BpOverlayRenderer : public BpInterface<IOverlayRenderer> {
  369
+public:
  370
+    BpOverlayRenderer(const sp<IBinder> &impl)
  371
+        : BpInterface<IOverlayRenderer>(impl) {
  372
+    }
  373
+
  374
+    virtual int32_t createOverlayRenderer(
  375
+        uint32_t bufferCount, int32_t displayWidth,  int32_t displayHeight,
  376
+        uint32_t colorFormat, int32_t decodedWidth, int32_t decodedHeight,
  377
+        int infoType, void * info)
  378
+    {
  379
+        Parcel data, reply;
  380
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  381
+        data.writeInt32(bufferCount);
  382
+        data.writeInt32(displayWidth);
  383
+        data.writeInt32(displayHeight);
  384
+        data.writeInt32(colorFormat);
  385
+        data.writeInt32(decodedWidth);
  386
+        data.writeInt32(decodedHeight);
  387
+        data.writeInt32(infoType);
  388
+        remote()->transact(CREATE_OVERLAY_RENDERER, data, &reply);
  389
+        return reply.readInt32();
  390
+    }
  391
+
  392
+    virtual void releaseMe()
  393
+    {
  394
+        Parcel data, reply;
  395
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  396
+        remote()->transact(RELEASE, data, &reply);
  397
+    }
  398
+
  399
+    virtual uint32_t getBufferCount()
  400
+    {
  401
+        Parcel data, reply;
  402
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  403
+        remote()->transact(GET_BUFFER_COUNT, data, &reply);
  404
+        return reply.readInt32();
  405
+    }
  406
+
  407
+    virtual sp<IMemory> getBuffer(uint32_t index)
  408
+    {
  409
+        Parcel data, reply;
  410
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  411
+        data.writeInt32(index);
  412
+        remote()->transact(GET_BUFFER, data, &reply);
  413
+        sp<IMemory> params = interface_cast<IMemory>(reply.readStrongBinder());
  414
+        return params;
  415
+    }
  416
+
  417
+    virtual int32_t dequeueBuffer(uint32_t *index)
  418
+    {
  419
+        Parcel data, reply;
  420
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  421
+        remote()->transact(DEQUEUE_BUFFER, data, &reply);
  422
+        int32_t err = reply.readInt32();
  423
+        *index = reply.readInt32();
  424
+        return err;
  425
+    }
  426
+
  427
+    virtual int32_t queueBuffer(uint32_t index)
  428
+    {
  429
+        Parcel data, reply;
  430
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  431
+        data.writeInt32(index);
  432
+        remote()->transact(QUEUE_BUFFER, data, &reply);
  433
+        return reply.readInt32();
  434
+    }
  435
+
  436
+    virtual int32_t setOrientation(int32_t orientation, uint32_t flags)
  437
+    {
  438
+        Parcel data, reply;
  439
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  440
+        data.writeInt32(orientation);
  441
+        data.writeInt32(flags);
  442
+        remote()->transact(SET_ORIENTATION, data, &reply);
  443
+        return reply.readInt32();
  444
+    }
  445
+
  446
+    virtual int32_t setPosition(int32_t x, int32_t y)
  447
+    {
  448
+        Parcel data, reply;
  449
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  450
+        data.writeInt32(x);
  451
+        data.writeInt32(y);
  452
+        remote()->transact(SET_POSITION, data, &reply);
  453
+        return reply.readInt32();
  454
+    }
  455
+
  456
+    virtual int32_t setSize(uint32_t w, uint32_t h)
  457
+    {
  458
+        Parcel data, reply;
  459
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  460
+        data.writeInt32(w);
  461
+        data.writeInt32(h);
  462
+        remote()->transact(SET_SIZE, data, &reply);
  463
+        return reply.readInt32();
  464
+    }
  465
+
  466
+    virtual int32_t setCrop(uint32_t x, uint32_t y, uint32_t w, uint32_t h)
  467
+    {
  468
+        Parcel data, reply;
  469
+        data.writeInterfaceToken(IOverlayRenderer::getInterfaceDescriptor());
  470
+        data.writeInt32(x);
  471
+        data.writeInt32(y);
  472
+        data.writeInt32(w);
  473
+        data.writeInt32(h);
  474
+        remote()->transact(SET_CROP, data, &reply);
  475
+        return reply.readInt32();
  476
+    }
  477
+
  478
+};
  479
+
  480
+IMPLEMENT_META_INTERFACE(OverlayRenderer, "android.media.IOverlayRenderer");
  481
+
  482
+status_t BnOverlayRenderer::onTransact(
  483
+    uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
  484
+
  485
+    switch (code) {
  486
+
  487
+        case CREATE_OVERLAY_RENDERER:
  488
+        {
  489
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  490
+            uint32_t bufferCount = data.readInt32();
  491
+            int32_t displayWidth = data.readInt32();
  492
+            int32_t displayHeight = data.readInt32();
  493
+            uint32_t colorFormat = data.readInt32();
  494
+            int32_t decodedWidth = data.readInt32();
  495
+            int32_t decodedHeight = data.readInt32();
  496
+            int infoType = data.readInt32();
  497
+            void *info;
  498
+            reply->writeInt32(createOverlayRenderer(bufferCount, displayWidth, displayHeight, colorFormat, decodedWidth, decodedHeight, infoType, info));
  499
+
  500
+            return NO_ERROR;
  501
+        }
  502
+
  503
+        case RELEASE:
  504
+        {
  505
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  506
+            releaseMe();
  507
+            return NO_ERROR;
  508
+        }
  509
+
  510
+        case GET_BUFFER_COUNT:
  511
+        {
  512
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  513
+
  514
+            uint32_t count = getBufferCount();
  515
+            reply->writeInt32(count);
  516
+
  517
+            return NO_ERROR;
  518
+        }
  519
+
  520
+        case GET_BUFFER:
  521
+        {
  522
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  523
+
  524
+            int32_t index = data.readInt32();
  525
+
  526
+            sp<IMemory> params  = getBuffer(index);
  527
+            reply->writeStrongBinder(params->asBinder());
  528
+
  529
+            return NO_ERROR;
  530
+        }
  531
+
  532
+        case DEQUEUE_BUFFER:
  533
+        {
  534
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  535
+
  536
+            uint32_t index;
  537
+
  538
+            int32_t err = dequeueBuffer(&index);
  539
+            reply->writeInt32(err);
  540
+            reply->writeInt32(index);
  541
+            return NO_ERROR;
  542
+        }
  543
+
  544
+        case QUEUE_BUFFER:
  545
+        {
  546
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  547
+
  548
+            int32_t index = data.readInt32();
  549
+
  550
+            reply->writeInt32(queueBuffer(index));
  551
+            return NO_ERROR;
  552
+        }
  553
+
  554
+        case SET_ORIENTATION:
  555
+        {
  556
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  557
+
  558
+            uint32_t orientation = data.readInt32();
  559
+            uint32_t flags = data.readInt32();
  560
+
  561
+            reply->writeInt32(setOrientation(orientation, flags));
  562
+            return NO_ERROR;
  563
+        }
  564
+
  565
+        case SET_POSITION:
  566
+        {
  567
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  568
+
  569
+            uint32_t x = data.readInt32();
  570
+            uint32_t y = data.readInt32();
  571
+
  572
+            reply->writeInt32(setPosition(x, y));
  573
+            return NO_ERROR;
  574
+        }
  575
+
  576
+        case SET_SIZE:
  577
+        {
  578
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  579
+
  580
+            uint32_t w = data.readInt32();
  581
+            uint32_t h = data.readInt32();
  582
+
  583
+            reply->writeInt32(setSize(w, h));
  584
+            return NO_ERROR;
  585
+        }
  586
+
  587
+        case SET_CROP:
  588
+        {
  589
+            CHECK_INTERFACE(IOverlayRenderer, data, reply);
  590
+
  591
+            uint32_t x = data.readInt32();
  592
+            uint32_t y = data.readInt32();
  593
+            uint32_t w = data.readInt32();
  594
+            uint32_t h = data.readInt32();
  595
+
  596
+            reply->writeInt32(setCrop(x, y, w, h));
  597
+            return NO_ERROR;
  598
+        }
  599
+
  600
+        default:
  601
+            return BBinder::onTransact(code, data, reply, flags);
  602
+    }
  603
+}
  604
+
  605
+
  606
+
  607
+}
  608
+
Txt media/libmedia/mediaplayer.cpp
... ...
@@ -504,6 +504,18 @@ status_t MediaPlayer::setVolume(float leftVolume, float rightVolume)
504 504
     return OK;
505 505
 }
506 506
 
  507
+#ifdef OMAP_ENHANCEMENT
  508
+status_t MediaPlayer::requestVideoCloneMode(bool enable)
  509
+{
  510
+    Mutex::Autolock _l(mLock);
  511
+    if (mPlayer != NULL) {
  512
+        return mPlayer->requestVideoCloneMode(enable);
  513
+    }
  514
+    return OK;
  515
+}
  516
+
  517
+#endif
  518
+
507 519
 status_t MediaPlayer::setAudioSessionId(int sessionId)
508 520
 {
509 521
     LOGV("MediaPlayer::setAudioSessionId(%d)", sessionId);
Txt media/libmediaplayerservice/Android.mk
... ...
@@ -71,6 +71,14 @@ ifeq ($(strip $(BOARD_USES_HW_MEDIAPLUGINS)),true)
71 71
     LOCAL_CFLAGS += -DUSE_BOARD_MEDIAPLUGIN
72 72
 endif
73 73
 
  74
+ifeq ($(OMAP_ENHANCEMENT),true)
  75
+
  76
+LOCAL_C_INCLUDES += $(TOP)/hardware/ti/omap3/liboverlay
  77
+
  78
+LOCAL_SHARED_LIBRARIES += libui
  79
+
  80
+endif
  81
+
74 82
 LOCAL_MODULE:= libmediaplayerservice
75 83
 
76 84
 include $(BUILD_SHARED_LIBRARY)
Txt media/libmediaplayerservice/MediaPlayerService.cpp
... ...
@@ -62,6 +62,9 @@
62 62
 #include "StagefrightPlayer.h"
63 63
 
64 64
 #include <OMX.h>
  65
+#ifdef OMAP_ENHANCEMENT
  66
+#include <media/OverlayRenderer.h>
  67
+#endif
65 68
 
66 69
 #ifdef USE_BOARD_MEDIAPLUGIN
67 70
 #define NO_OPENCORE 1
... ...
@@ -203,6 +206,11 @@ extmap FILE_EXTS [] =  {
203 206
         {".rtttl", SONIVOX_PLAYER},
204 207
         {".rtx", SONIVOX_PLAYER},
205 208
         {".ota", SONIVOX_PLAYER},
  209
+#ifdef OMAP_ENHANCEMENT
  210
+        {".wma", STAGEFRIGHT_PLAYER},
  211
+        {".wmv", STAGEFRIGHT_PLAYER},
  212
+        {".asf", STAGEFRIGHT_PLAYER},
  213
+#else
206 214
 #ifdef USE_BOARD_MEDIAPLUGIN
207 215
         {".ogg", STAGEFRIGHT_PLAYER},
208 216
 #endif
... ...
@@ -211,6 +219,7 @@ extmap FILE_EXTS [] =  {
211 219
         {".wmv", PV_PLAYER},
212 220
         {".asf", PV_PLAYER},
213 221
 #endif
  222
+#endif
214 223
         {".flac", FLAC_PLAYER},
215 224
 };
216 225
 
... ...
@@ -305,6 +314,18 @@ sp<IOMX> MediaPlayerService::getOMX() {
305 314
     return mOMX;
306 315
 }
307 316
 
  317
+#ifdef OMAP_ENHANCEMENT
  318
+sp<IOverlayRenderer> MediaPlayerService::getOverlayRenderer() {
  319
+    Mutex::Autolock autoLock(mLock);
  320
+
  321
+    if (mOverlayRenderer.get() == NULL) {
  322
+        mOverlayRenderer = new OverlayRenderer;
  323
+    }
  324
+
  325
+    return mOverlayRenderer;
  326
+}
  327
+#endif
  328
+
308 329
 status_t MediaPlayerService::AudioCache::dump(int fd, const Vector<String16>& args) const
309 330
 {
310 331
     const size_t SIZE = 256;
... ...
@@ -705,6 +726,13 @@ player_type getPlayerType(int fd, int64_t offset, int64_t length)
705 726
     if (ident == 0x5367674f) // 'OggS'
706 727
         return STAGEFRIGHT_PLAYER;
707 728
 
  729
+#ifdef OMAP_ENHANCEMENT
  730
+    if (ident == 0x75b22630) {
  731
+        LOGV("The magic number for .asf files, i.e. wmv and wma content");
  732
+        LOGV("These will be supported through stagefright.");
  733
+        return STAGEFRIGHT_PLAYER;
  734
+    }
  735
+#else
708 736
 #ifndef NO_OPENCORE
709 737
     if (ident == 0x75b22630) {
710 738
         // The magic number for .asf files, i.e. wmv and wma content.
... ...
@@ -713,9 +741,9 @@ player_type getPlayerType(int fd, int64_t offset, int64_t length)
713 741
     }
714 742
 #endif
715 743
 
  744
+#endif
716 745
     if (ident == 0x43614c66) // 'fLaC'
717 746
         return FLAC_PLAYER;
718  
-
719 747
     // Some kind of MIDI?
720 748
     EAS_DATA_HANDLE easdata;
721 749
     if (EAS_Init(&easdata) == EAS_SUCCESS) {
... ...
@@ -1007,6 +1035,16 @@ status_t MediaPlayerService::Client::resume() {
1007 1035
     return p->resume();
1008 1036
 }
1009 1037
 
  1038
+#ifdef OMAP_ENHANCEMENT
  1039
+status_t MediaPlayerService::Client::requestVideoCloneMode(bool enable) {
  1040
+    sp<MediaPlayerBase> p = getPlayer();
  1041
+    if (p == 0) return UNKNOWN_ERROR;
  1042
+
  1043
+    return p->requestVideoCloneMode(enable);
  1044
+}
  1045
+
  1046
+#endif
  1047
+
1010 1048
 status_t MediaPlayerService::Client::prepareAsync()
1011 1049
 {
1012 1050
     LOGV("[%d] prepareAsync", mConnId);
Txt media/libmediaplayerservice/MediaPlayerService.h
... ...
@@ -36,6 +36,9 @@ class IMediaRecorder;
36 36
 class IMediaMetadataRetriever;
37 37
 class IOMX;
38 38
 class MediaRecorderClient;
  39
+#ifdef OMAP_ENHANCEMENT
  40
+class IOverlayRenderer;
  41
+#endif
39 42
 
40 43
 #define CALLBACK_ANTAGONIZER 0
41 44
 #if CALLBACK_ANTAGONIZER
... ...
@@ -194,7 +197,9 @@ public:
194 197
     virtual sp<IMemory>         decode(const char* url, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
195 198
     virtual sp<IMemory>         decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, int* pFormat);
196 199
     virtual sp<IOMX>            getOMX();
197  
-
  200
+#ifdef OMAP_ENHANCEMENT
  201
+    virtual sp<IOverlayRenderer>  getOverlayRenderer();
  202
+#endif
198 203
     virtual status_t            dump(int fd, const Vector<String16>& args);
199 204
 
200 205
             void                removeClient(wp<Client> client);
... ...
@@ -228,6 +233,9 @@ private:
228 233
         virtual status_t        resume();
229 234
         virtual status_t        setAuxEffectSendLevel(float level);
230 235
         virtual status_t        attachAuxEffect(int effectId);
  236
+#ifdef OMAP_ENHANCEMENT
  237
+        virtual status_t        requestVideoCloneMode(bool enable);
  238
+#endif
231 239
 
232 240
         sp<MediaPlayerBase>     createPlayer(player_type playerType);
233 241
 
... ...
@@ -305,6 +313,9 @@ private:
305 313
                 SortedVector< wp<MediaRecorderClient> > mMediaRecorderClients;
306 314
                 int32_t                     mNextConnId;
307 315
                 sp<IOMX>                    mOMX;
  316
+#ifdef OMAP_ENHANCEMENT
  317
+                sp<IOverlayRenderer> mOverlayRenderer;
  318
+#endif
308 319
 };
309 320
 
310 321
 // ----------------------------------------------------------------------------
Txt media/libmediaplayerservice/StagefrightPlayer.cpp
... ...
@@ -150,6 +150,12 @@ status_t StagefrightPlayer::resume() {
150 150
     return mPlayer->resume();
151 151
 }
152 152
 
  153
+#ifdef OMAP_ENHANCEMENT
  154
+status_t StagefrightPlayer::requestVideoCloneMode(bool enable) {
  155
+    return mPlayer->requestVideoCloneMode(enable);
  156
+}
  157
+#endif
  158
+
153 159
 status_t StagefrightPlayer::invoke(const Parcel &request, Parcel *reply) {
154 160
     return INVALID_OPERATION;
155 161
 }
Txt media/libmediaplayerservice/StagefrightPlayer.h
... ...
@@ -52,6 +52,9 @@ public:
52 52
     virtual void setAudioSink(const sp<AudioSink> &audioSink);
53 53
     virtual status_t suspend();
54 54
     virtual status_t resume();
  55
+#ifdef OMAP_ENHANCEMENT
  56
+    virtual status_t requestVideoCloneMode(bool enable);
  57
+#endif
55 58
 
56 59
     virtual status_t getMetadata(
57 60
             const media::Metadata::Filter& ids, Parcel *records);
Txt media/libmediaplayerservice/StagefrightRecorder.cpp 100644 → 100755
... ...
@@ -678,19 +678,6 @@ status_t StagefrightRecorder::start() {
678 678
 }
679 679
 
680 680
 sp<MediaSource> StagefrightRecorder::createAudioSource() {
681  
-    sp<AudioSource> audioSource =
682  
-        new AudioSource(
683  
-                mAudioSource,
684  
-                mSampleRate,
685  
-                mAudioChannels);
686  
-
687  
-    status_t err = audioSource->initCheck();
688  
-
689  
-    if (err != OK) {
690  
-        LOGE("audio source is not initialized");
691  
-        return NULL;
692  
-    }
693  
-
694 681
     sp<MetaData> encMeta = new MetaData;
695 682
     const char *mime;
696 683
     switch (mAudioEncoder) {
... ...
@@ -710,6 +697,22 @@ sp<MediaSource> StagefrightRecorder::createAudioSource() {
710 697
     }
711 698
     encMeta->setCString(kKeyMIMEType, mime);
712 699
 
  700
+    mSampleRate = mEncoderProfiles->getAudioEncoderParamByName(
  701
+                   "enc.aud.hz.min", mAudioEncoder);
  702
+
  703
+    sp<AudioSource> audioSource =
  704
+        new AudioSource(
  705
+                mAudioSource,
  706
+                mSampleRate,
  707
+                mAudioChannels);
  708
+
  709
+    status_t err = audioSource->initCheck();
  710
+
  711
+    if (err != OK) {
  712
+        LOGE("audio source is not initialized");
  713
+        return NULL;
  714
+    }
  715
+
713 716
     int32_t maxInputSize;
714 717
     CHECK(audioSource->getFormat()->findInt32(
715 718
                 kKeyMaxInputSize, &maxInputSize));
... ...
@@ -725,9 +728,24 @@ sp<MediaSource> StagefrightRecorder::createAudioSource() {
725 728
     OMXClient client;
726 729
     CHECK_EQ(client.connect(), OK);
727 730
 
728  
-    sp<MediaSource> audioEncoder =
  731
+    sp<MediaSource> audioEncoder;
  732
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  733
+#define MAX_RESOLUTION 414720
  734
+    if ((mAudioEncoder == AUDIO_ENCODER_AAC) &&
  735
+        (mVideoWidth*mVideoHeight > MAX_RESOLUTION)) {
  736
+        audioEncoder =
  737
+            OMXCodec::Create(client.interface(), encMeta,
  738
+                             true /* createEncoder */, audioSource,
  739
+                             "OMX.ITTIAM.AAC.encode");
  740
+
  741
+    } else {
  742
+#endif
  743
+    audioEncoder =
729 744
         OMXCodec::Create(client.interface(), encMeta,
730 745
                          true /* createEncoder */, audioSource);
  746
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  747
+    }
  748
+#endif
731 749
     mAudioSourceNode = audioSource;
732 750
 
733 751
     return audioEncoder;
... ...
@@ -901,12 +919,63 @@ void StagefrightRecorder::clipVideoFrameRate() {
901 919
     }
902 920
 }
903 921
 
  922
+/* Needs to be check max-bitrate in here to make sure that encoding with right parameters */
  923
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  924
+
  925
+#define ARRAY_SIZE(array) (sizeof array / sizeof array[0])
  926
+
  927
+typedef struct {
  928
+    size_t level;
  929
+    size_t maxBitRate;
  930
+    size_t maxFrameSizeinMbs;
  931
+    size_t maxMbsPerSecond;
  932
+} omap3_dsp_h264_supported;
  933
+
  934
+/* Below table synced with inside codec's */
  935
+const omap3_dsp_h264_supported _h264_supported[] = {
  936
+                            {10, 64000, 99, 1485},
  937
+                            {11, 192000, 396, 3000},
  938
+                            {12, 384000, 396, 6000},
  939
+                            {20, 2000000, 396, 11880},
  940
+                            {21, 4000000, 792, 19800},
  941
+                            {22, 4000000, 1620, 20250},
  942
+                            {30, 10000000, 1620, 40500}};
  943
+
  944
+static int _get_maxrate_in_mbs(int width, int height, int fps) {
  945
+    int mps = (width / 16) * (height / 16) * fps; /* Max macroblocks per second */
  946
+    int i;
  947
+    int maxrate = -1;
  948
+
  949
+    for (i = 0; i < ARRAY_SIZE(_h264_supported); i++) {
  950
+        if (mps < _h264_supported[i].maxMbsPerSecond) {
  951
+            maxrate = _h264_supported[i].maxBitRate;
  952
+            break;
  953
+        }
  954
+    }
  955
+
  956
+    // not found, set max.
  957
+    if (maxrate == -1) maxrate = _h264_supported[ARRAY_SIZE(_h264_supported)-1].maxBitRate;
  958
+
  959
+    return maxrate;
  960
+}
  961
+#endif /* defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3) */
  962
+
904 963
 void StagefrightRecorder::clipVideoBitRate() {
905 964
     LOGV("clipVideoBitRate: encoder %d", mVideoEncoder);
906  
-    int minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
907  
-                        "enc.vid.bps.min", mVideoEncoder);
908  
-    int maxBitRate = mEncoderProfiles->getVideoEncoderParamByName(
909  
-                        "enc.vid.bps.max", mVideoEncoder);
  965
+    int minBitRate;
  966
+    int maxBitRate;
  967
+
  968
+    minBitRate = mEncoderProfiles->getVideoEncoderParamByName(
  969
+        "enc.vid.bps.min", mVideoEncoder);
  970
+
  971
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  972
+    if (mVideoEncoder == 2) /* H.264 */
  973
+        maxBitRate = _get_maxrate_in_mbs(mVideoWidth, mVideoHeight, mFrameRate);
  974
+    else
  975
+#endif
  976
+        maxBitRate = mEncoderProfiles->getVideoEncoderParamByName(
  977
+            "enc.vid.bps.max", mVideoEncoder);
  978
+
910 979
     if (mVideoBitRate < minBitRate) {
911 980
         LOGW("Intended video encoding bit rate (%d bps) is too small"
912 981
              " and will be set to (%d bps)", mVideoBitRate, minBitRate);
... ...
@@ -1045,6 +1114,18 @@ status_t StagefrightRecorder::setupVideoEncoder(sp<MediaSource> *source) {
1045 1114
     CHECK(meta->findInt32(kKeyStride, &stride));
1046 1115
     CHECK(meta->findInt32(kKeySliceHeight, &sliceHeight));
1047 1116
     CHECK(meta->findInt32(kKeyColorFormat, &colorFormat));
  1117
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1118
+    int32_t paddedWidth, paddedHeight, seiEncodingType, mS3DCamera;
  1119
+    const char *frameLayoutStr;
  1120
+    CHECK(meta->findInt32(kKeyPaddedWidth, &paddedWidth));
  1121
+    CHECK(meta->findInt32(kKeyPaddedHeight, &paddedHeight));
  1122
+    CHECK(meta->findInt32(kKeyS3dSupported, &mS3DCamera));
  1123
+    if(mS3DCamera)
  1124
+    {
  1125
+        CHECK(meta->findInt32(kKeySEIEncodingType, &seiEncodingType));
  1126
+        CHECK(meta->findCString(kKeyFrameLayout, &frameLayoutStr));
  1127
+    }
  1128
+#endif
1048 1129
 
1049 1130
     enc_meta->setInt32(kKeyWidth, width);
1050 1131
     enc_meta->setInt32(kKeyHeight, height);
... ...
@@ -1052,6 +1133,17 @@ status_t StagefrightRecorder::setupVideoEncoder(sp<MediaSource> *source) {
1052 1133
     enc_meta->setInt32(kKeyStride, stride);
1053 1134
     enc_meta->setInt32(kKeySliceHeight, sliceHeight);
1054 1135
     enc_meta->setInt32(kKeyColorFormat, colorFormat);
  1136
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1137
+    enc_meta->setInt32(kKeyPaddedWidth, paddedWidth);
  1138
+    enc_meta->setInt32(kKeyPaddedHeight, paddedHeight);
  1139
+    enc_meta->setInt32(kKeyS3dSupported, mS3DCamera);
  1140
+    if(mS3DCamera)
  1141
+    {
  1142
+        enc_meta->setInt32(kKeySEIEncodingType, seiEncodingType);
  1143
+        enc_meta->setCString(kKeyFrameLayout, frameLayoutStr);
  1144
+    }
  1145
+#endif
  1146
+
1055 1147
     if (mVideoTimeScale > 0) {
1056 1148
         enc_meta->setInt32(kKeyTimeScale, mVideoTimeScale);
1057 1149
     }
... ...
@@ -1103,12 +1195,14 @@ status_t StagefrightRecorder::startMPEG4Recording() {
1103 1195
     status_t err = OK;
1104 1196
     sp<MediaWriter> writer = new MPEG4Writer(dup(mOutputFd));
1105 1197
 
  1198
+#if !defined(OMAP_ENHANCEMENT)
1106 1199
     // Add audio source first if it exists
1107 1200
     if (mAudioSource != AUDIO_SOURCE_LIST_END) {
1108 1201
         err = setupAudioEncoder(writer);
1109 1202
         if (err != OK) return err;
1110 1203
         totalBitRate += mAudioBitRate;
1111 1204
     }
  1205
+#endif
1112 1206
     if (mVideoSource == VIDEO_SOURCE_DEFAULT
1113 1207
             || mVideoSource == VIDEO_SOURCE_CAMERA) {
1114 1208
         sp<MediaSource> encoder;
... ...
@@ -1117,6 +1211,16 @@ status_t StagefrightRecorder::startMPEG4Recording() {
1117 1211
         writer->addSource(encoder);
1118 1212
         totalBitRate += mVideoBitRate;
1119 1213
     }
  1214
+#if defined(OMAP_ENHANCEMENT)
  1215
+    // Starting Audio after video to fix AV-Sync issue. The AV-Sync issue here refers to lip-sync not achieved in recorded video.
  1216
+    // This is due to the audio track thread blocking the video thread for approx half a second which results in audio recorded
  1217
+    // half a second earlier than video. This when played back results in audio/video out of sync.
  1218
+    if (mAudioSource != AUDIO_SOURCE_LIST_END) {
  1219
+        err = setupAudioEncoder(writer);
  1220
+        if (err != OK) return err;
  1221
+        totalBitRate += mAudioBitRate;
  1222
+    }
  1223
+#endif
1120 1224
 
1121 1225
     if (mInterleaveDurationUs > 0) {
1122 1226
         reinterpret_cast<MPEG4Writer *>(writer.get())->
Txt media/libstagefright/ASFExtractor.cpp
... ...
@@ -0,0 +1,179 @@
  1
+/**
  2
+ *****************************************************************************
  3
+ *
  4
+ *  @file     ASFExtractor.cpp
  5
+ *
  6
+ *  @brief    This file works as a wrapper to the ASFExtractor class
  7
+ *
  8
+ *****************************************************************************
  9
+ */
  10
+
  11
+#define LOG_TAG "ASFDummyExtractor"
  12
+#include <utils/Log.h>
  13
+
  14
+#include <media/stagefright/MediaSource.h>
  15
+#include <media/stagefright/MetaData.h>
  16
+#include <media/stagefright/MediaExtractor.h>
  17
+#include <utils/Vector.h>
  18
+#include <dlfcn.h>   /* For dynamic loading */
  19
+#include "include/ASFExtractor.h"
  20
+
  21
+
  22
+namespace android {
  23
+    static void * pASFHandle = NULL;
  24
+
  25
+ASFExtractor::ASFExtractor(const sp<DataSource> &source) {
  26
+    const char *errstr;
  27
+    LOGD("Dummy ASFExtractor contructor");
  28
+
  29
+    pASFParser = new ASF_WRAPER;
  30
+
  31
+    pASFParser->ASFExtractor =     ( ASFExtractorImpl* (*)(const android::sp<android::DataSource>&))dlsym(pASFHandle, "ASFExtractor");
  32
+    if((errstr = dlerror()) != NULL){
  33
+        LOGE("dlsym(), err: %s", errstr);
  34
+        dlclose(pASFHandle);
  35
+        delete pASFParser;
  36
+        return;
  37
+    }
  38
+    pASFParser->destructorASFExtractor =     (void (*)(ASFExtractorImpl *))dlsym(pASFHandle, "destructorASFExtractor");
  39
+    if((errstr = dlerror()) != NULL){
  40
+        LOGE("dlsym(), err: %s", errstr);
  41
+        dlclose(pASFHandle);
  42
+        delete pASFParser;
  43
+        return;
  44
+    }
  45
+    pASFParser->countTracks =       (size_t (*)(ASFExtractorImpl *))dlsym(pASFHandle, "countTracks");
  46
+    if((errstr = dlerror()) != NULL){
  47
+        LOGE("dlsym(), err: %s", errstr);
  48
+        dlclose(pASFHandle);
  49
+        delete pASFParser;
  50
+        return;
  51
+    }
  52
+    pASFParser->getTrack =          (android::sp<android::MediaSource> (*)(size_t, ASFExtractorImpl *))dlsym(pASFHandle, "getTrack");
  53
+    if((errstr = dlerror()) != NULL){
  54
+        LOGE("dlsym(), err: %s", errstr);
  55
+        dlclose(pASFHandle);
  56
+        delete pASFParser;
  57
+        return;
  58
+    }
  59
+    pASFParser->getTrackMetaData =  (android::sp<android::MetaData> (*)(size_t, uint32_t, ASFExtractorImpl *))dlsym(pASFHandle, "getTrackMetaData");
  60
+    if((errstr = dlerror()) != NULL){
  61
+        LOGE("dlsym(), err: %s", errstr);
  62
+        dlclose(pASFHandle);
  63
+        delete pASFParser;
  64
+        return;
  65
+    }
  66
+    pASFParser->getMetaData =       (android::sp<android::MetaData> (*)(ASFExtractorImpl *))dlsym(pASFHandle, "getMetaData");
  67
+    if((errstr = dlerror()) != NULL){
  68
+        LOGE("dlsym(), err: %s", errstr);
  69
+        dlclose(pASFHandle);
  70
+        delete pASFParser;
  71
+        return;
  72
+    }
  73
+
  74
+
  75
+    mHandle = (*pASFParser->ASFExtractor)(source);
  76
+}
  77
+
  78
+ASFExtractor::~ASFExtractor() {
  79
+    LOGD("Dummy ASFExtractor destructor");
  80
+    if(!pASFParser) {
  81
+        return;
  82
+    }
  83
+
  84
+    (pASFParser->destructorASFExtractor)(mHandle);
  85
+
  86
+  // Commented to handle the MediaSource::getFormat() issue.
  87
+    delete pASFParser;
  88
+    pASFParser = NULL;
  89
+}
  90
+
  91
+size_t ASFExtractor::countTracks() {
  92
+    LOGV("Dummy ASFExtractor::countTracks()");
  93
+    if(!pASFParser) {
  94
+        return 0;
  95
+    }
  96
+
  97
+    return (*pASFParser->countTracks)(mHandle);
  98
+}
  99
+
  100
+sp<MediaSource> ASFExtractor::getTrack(size_t index) {
  101
+    LOGV("Dummy ASFExtractor::getTrack()");
  102
+    if(!pASFParser) {
  103
+        return NULL;
  104
+    }
  105
+
  106
+    return (*pASFParser->getTrack)(index, mHandle);
  107
+}
  108
+
  109
+sp<MetaData> ASFExtractor::getTrackMetaData(
  110
+        size_t index, uint32_t flags) {
  111
+    if(!pASFParser) {
  112
+        return NULL;
  113
+    }
  114
+
  115
+    return (*pASFParser->getTrackMetaData)(index, flags, mHandle);
  116
+}
  117
+
  118
+sp<MetaData> ASFExtractor::getMetaData() {
  119
+    LOGV("Dummy ASFExtractor::getMetaData()");
  120
+    if(!pASFParser) {
  121
+        return NULL;
  122
+    }
  123
+
  124
+    return (*pASFParser->getMetaData)(mHandle);
  125
+}
  126
+
  127
+bool SniffASF(const sp<DataSource> &source,
  128
+              String8 *mimeType,
  129
+              float *confidence,
  130
+              sp<AMessage> *meta)
  131
+{
  132
+    const char *errstr;
  133
+
  134
+    static bool (*pSniffASF)(
  135
+        const sp<DataSource> &source,
  136
+        String8 *mimeType,
  137
+        float *confidence,
  138
+        sp<AMessage> *meta);
  139
+
  140
+    LOGV("Dummy SniffASF function");
  141
+
  142
+    if(!pASFHandle) {
  143
+        pASFHandle = dlopen("/system/lib/libittiam_asfextractor.so", RTLD_LAZY | RTLD_GLOBAL);
  144
+        if((errstr = dlerror()) != NULL){
  145
+            LOGE("dlopen() err: %s", errstr);
  146
+            return false;
  147
+        }
  148
+    }
  149
+
  150
+    pSniffASF =(bool (*)(const android::sp<android::DataSource>&, android::String8*, float*, android::sp<android::AMessage>*)) dlsym(pASFHandle, "SniffASF");
  151
+    if((errstr = dlerror()) != NULL) {
  152
+        LOGE("Error dlsym(pSniffASF), err: %s", errstr);
  153
+        return false;
  154
+    }
  155
+    return (*pSniffASF)(source, mimeType, confidence, meta);
  156
+}
  157
+
  158
+bool isASFParserAvailable()
  159
+{
  160
+    FILE *pF;
  161
+
  162
+    pF = fopen("/system/lib/libittiam_asfextractor.so", "r");
  163
+    if(!pF) {
  164
+        LOGW("ASF parser is not available");
  165
+        return false;
  166
+    }
  167
+    fclose(pF);
  168
+
  169
+    return true;
  170
+}
  171
+
  172
+void closeASFLib()
  173
+{
  174
+    if (pASFHandle) {
  175
+        dlclose(pASFHandle);
  176
+        pASFHandle = NULL;
  177
+     }
  178
+}
  179
+}  // namespace android
Txt media/libstagefright/Android.mk
... ...
@@ -2,7 +2,9 @@ LOCAL_PATH:= $(call my-dir)
2 2
 include $(CLEAR_VARS)
3 3
 
4 4
 include frameworks/base/media/libstagefright/codecs/common/Config.mk
5  
-
  5
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
  6
+LOCAL_CFLAGS += -DTARGET_OMAP4 -DARM_4K_PAGE_SIZE=4096
  7
+endif
6 8
 LOCAL_SRC_FILES:=                         \
7 9
         AMRExtractor.cpp                  \
8 10
         AMRWriter.cpp                     \
... ...
@@ -44,13 +46,35 @@ LOCAL_SRC_FILES:=                         \
44 46
         avc_utils.cpp                     \
45 47
         string.cpp
46 48
 
  49
+ifeq ($(OMAP_ENHANCEMENT),true)
  50
+LOCAL_SRC_FILES += \
  51
+    ASFExtractor.cpp
  52
+endif
  53
+
  54
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
  55
+LOCAL_SRC_FILES +=               \
  56
+        TIVideoConfigParser.cpp  \
  57
+        TISEIMessagesParser.cpp
  58
+endif
47 59
 LOCAL_C_INCLUDES:= \
48 60
   $(JNI_H_INCLUDE) \
49 61
         $(TOP)/frameworks/base/include/media/stagefright/openmax \
50 62
         $(TOP)/external/tremolo \
51 63
         $(TOP)/external/flac/include \
52 64
         $(TOP)/frameworks/base/media/libstagefright/rtsp
  65
+ifeq ($(OMAP_ENHANCEMENT),true)
  66
+LOCAL_C_INCLUDES += \
  67
+        $(TOP)/hardware/ti/omap3/liboverlay
  68
+endif
53 69
 
  70
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
  71
+LOCAL_C_INCLUDES +=          \
  72
+  hardware/ti/omx/ducati/domx/system/omx_core/inc \
  73
+  hardware/ti/omap3/camera-omap4/inc
  74
+endif
  75
+ifeq ($(OMAP_ENHANCEMENT),true)
  76
+LOCAL_C_INCLUDES += $(TOP)/hardware/ti/omap3/liboverlay
  77
+endif
54 78
 LOCAL_SHARED_LIBRARIES := \
55 79
         libbinder         \
56 80
         libmedia          \
... ...
@@ -63,6 +87,11 @@ LOCAL_SHARED_LIBRARIES := \
63 87
         libcamera_client  \
64 88
         libFLAC
65 89
 
  90
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
  91
+LOCAL_SHARED_LIBRARIES += \
  92
+  libcamera
  93
+endif
  94
+
66 95
 LOCAL_STATIC_LIBRARIES := \
67 96
         libstagefright_aacdec \
68 97
         libstagefright_aacenc \
Txt media/libstagefright/AudioPlayer.cpp
... ...
@@ -26,7 +26,9 @@
26 26
 #include <media/stagefright/MediaErrors.h>
27 27
 #include <media/stagefright/MediaSource.h>
28 28
 #include <media/stagefright/MetaData.h>
29  
-
  29
+#ifdef OMAP_ENHANCEMENT
  30
+#include <media/stagefright/MediaErrors.h>
  31
+#endif
30 32
 #include "include/AwesomePlayer.h"
31 33
 
32 34
 namespace android {
... ...
@@ -68,6 +70,11 @@ status_t AudioPlayer::start(bool sourceAlreadyStarted) {
68 70
     CHECK(!mStarted);
69 71
     CHECK(mSource != NULL);
70 72
 
  73
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  74
+    mRealTimeInterpolation = GetSystemTimeuSec();
  75
+#endif
  76
+
  77
+
71 78
     status_t err;
72 79
     if (!sourceAlreadyStarted) {
73 80
         err = mSource->start();
... ...
@@ -182,10 +189,24 @@ void AudioPlayer::pause(bool playPendingSamples) {
182 189
         }
183 190
     }
184 191
 }
  192
+#ifdef OMAP_ENHANCEMENT
  193
+void AudioPlayer::flush() {
  194
+    CHECK(mStarted);
185 195
 
  196
+    if (mAudioSink.get() != NULL) {
  197
+        mAudioSink->flush();
  198
+    } else {
  199
+        mAudioTrack->flush();
  200
+    }
  201
+}
  202
+#endif
186 203
 void AudioPlayer::resume() {
187 204
     CHECK(mStarted);
188 205
 
  206
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  207
+    mRealTimeInterpolation = GetSystemTimeuSec();
  208
+#endif
  209
+
189 210
     if (mAudioSink.get() != NULL) {
190 211
         mAudioSink->start();
191 212
     } else {
... ...
@@ -387,12 +408,61 @@ size_t AudioPlayer::fillBuffer(void *data, size_t size) {
387 408
     Mutex::Autolock autoLock(mLock);
388 409
     mNumFramesPlayed += size_done / mFrameSize;
389 410
 
  411
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  412
+    //Reset the interpolation time
  413
+    mRealTimeInterpolation = GetSystemTimeuSec();
  414
+#endif
390 415
     return size_done;
391 416
 }
392 417
 
  418
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  419
+//Function to get the system time
  420
+int64_t AudioPlayer::GetSystemTimeuSec(){
  421
+    struct timeval tv;
  422
+    gettimeofday(&tv, NULL);
  423
+    return ((int64_t)tv.tv_sec * 1000000 + tv.tv_usec);
  424
+}
  425
+#endif
  426
+
393 427
 int64_t AudioPlayer::getRealTimeUs() {
394 428
     Mutex::Autolock autoLock(mLock);
  429
+
  430
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  431
+    int64_t realtime = getRealTimeUsLocked();
  432
+
  433
+    //We need to interpolate the time to reolution of 1msec
  434
+    //to get precise posting of buffers
  435
+    int64_t deltaFromPosting = 0;
  436
+
  437
+    //Take care of first time read in case no frame has returned
  438
+    if(mRealTimeInterpolation ==0){
  439
+        LOGV("reset %lld",mRealTimeInterpolation);
  440
+        mRealTimeInterpolation = GetSystemTimeuSec();
  441
+        deltaFromPosting = 0;
  442
+    }
  443
+    else{
  444
+        //Fetch the delta time from the last time we got the audio
  445
+        //frame completion. We are only intereseted in delata
  446
+        LOGV("mRealTimeInterpolation %lld = %lld - %lld",
  447
+          ((int64_t)GetSystemTimeuSec()) - mRealTimeInterpolation,
  448
+          ((int64_t)GetSystemTimeuSec()), mRealTimeInterpolation);
  449
+
  450
+        deltaFromPosting =  GetSystemTimeuSec() - mRealTimeInterpolation;
  451
+    }
  452
+
  453
+    //if audio hangs we should drop frames. We will wait worst case of
  454
+    //1 Sec
  455
+    if((deltaFromPosting > 1000000) || (deltaFromPosting < 0) ) {
  456
+        LOGE("To late ... there is a hang %lld",deltaFromPosting);
  457
+        return realtime;
  458
+    }
  459
+
  460
+    LOGV("IPT %lld",deltaFromPosting/1000);
  461
+    return realtime + deltaFromPosting;
  462
+#else
395 463
     return getRealTimeUsLocked();
  464
+#endif
  465
+
396 466
 }
397 467
 
398 468
 int64_t AudioPlayer::getRealTimeUsLocked() const {
Txt media/libstagefright/AwesomePlayer.cpp
... ...
@@ -49,10 +49,27 @@
49 49
 
50 50
 #include <media/stagefright/foundation/ALooper.h>
51 51
 
52  
-namespace android {
  52
+#ifdef OMAP_ENHANCEMENT
  53
+#include "include/ASFExtractor.h"
  54
+
  55
+#if defined(TARGET_OMAP4)
  56
+#include <OMX_TI_Video.h>
  57
+#include <OMX_TI_Common.h>
  58
+#include <OMX_TI_IVCommon.h>
  59
+#endif
  60
+
  61
+#endif
53 62
 
  63
+namespace android {
  64
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  65
+extern void updateMetaData(sp<MetaData> meta_track);
  66
+#endif
54 67
 static int64_t kLowWaterMarkUs = 2000000ll;  // 2secs
  68
+#ifndef OMAP_ENHANCEMENT
55 69
 static int64_t kHighWaterMarkUs = 10000000ll;  // 10secs
  70
+#else
  71
+static int64_t kHighWaterMarkUs = 6000000ll;  // 6secs
  72
+#endif
56 73
 static const size_t kLowWaterMarkBytes = 40000;
57 74
 static const size_t kHighWaterMarkBytes = 200000;
58 75
 
... ...
@@ -95,6 +112,28 @@ struct AwesomeRemoteRenderer : public AwesomeRenderer {
95 112
         }
96 113
     }
97 114
 
  115
+#ifdef OMAP_ENHANCEMENT
  116
+    virtual Vector< sp<IMemory> > getBuffers(){
  117
+        return mTarget->getBuffers();
  118
+    }
  119
+
  120
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie) {
  121
+        return mTarget->setCallback(cb, cookie);
  122
+    }
  123
+
  124
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling) {
  125
+         mTarget->set_s3d_frame_layout(s3d_mode, s3d_fmt, s3d_order, s3d_subsampling);
  126
+    }
  127
+
  128
+    virtual void resizeRenderer(void* resize_params) {
  129
+        mTarget->resizeRenderer(resize_params);
  130
+    }
  131
+
  132
+    virtual void requestRendererClone(bool enable) {
  133
+        mTarget->requestRendererClone(enable);
  134
+    }
  135
+#endif
  136
+
98 137
 private:
99 138
     sp<IOMXRenderer> mTarget;
100 139
 
... ...
@@ -133,6 +172,18 @@ struct AwesomeLocalRenderer : public AwesomeRenderer {
133 172
         mTarget->render(data, size, NULL);
134 173
     }
135 174
 
  175
+#ifdef OMAP_ENHANCEMENT
  176
+    virtual Vector< sp<IMemory> > getBuffers(){
  177
+        return mTarget->getBuffers();
  178
+    }
  179
+    virtual void resizeRenderer(void* resize_params) {
  180
+        mTarget->resizeRenderer(resize_params);
  181
+    }
  182
+    virtual void requestRendererClone(bool enable) {
  183
+        mTarget->requestRendererClone(enable);
  184
+    }
  185
+#endif
  186
+
136 187
 protected:
137 188
     virtual ~AwesomeLocalRenderer() {
138 189
         delete mTarget;
... ...
@@ -238,6 +289,13 @@ status_t AwesomeLocalRenderer::init(
238 289
     return ((SoftwareRenderer *)mTarget)->initCheck();
239 290
 }
240 291
 
  292
+#ifdef OMAP_ENHANCEMENT
  293
+static void releaseRenderedBufferCallback(const sp<IMemory>& mem, void *cookie){
  294
+    AwesomePlayer *ap = static_cast<AwesomePlayer *>(cookie);
  295
+    ap->releaseRenderedBuffer(mem);
  296
+}
  297
+#endif
  298
+
241 299
 AwesomePlayer::AwesomePlayer()
242 300
     : mQueueStarted(false),
243 301
       mTimeSource(NULL),
... ...
@@ -245,7 +303,16 @@ AwesomePlayer::AwesomePlayer()
245 303
       mAudioPlayer(NULL),
246 304
       mFlags(0),
247 305
       mExtractorFlags(0),
  306
+#ifdef OMAP_ENHANCEMENT
  307
+      mBufferReleaseCallbackSet(false),
  308
+      mIsFirstVideoBuffer(false),
  309
+      mFirstVideoBufferResult(OK),
  310
+      mFirstVideoBuffer(NULL),
  311
+      mExtractorType(NULL),
  312
+      mExtractor(NULL),
  313
+#else
248 314
       mLastVideoBuffer(NULL),
  315
+#endif
249 316
       mVideoBuffer(NULL),
250 317
       mSuspensionState(NULL) {
251 318
     CHECK_EQ(mClient.connect(), OK);
... ...
@@ -264,6 +331,16 @@ AwesomePlayer::AwesomePlayer()
264 331
 
265 332
     mAudioStatusEventPending = false;
266 333
 
  334
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  335
+    mS3Dparams.active = S3D_MODE_OFF;
  336
+    mS3Dparams.mode = S3D_MODE_OFF;
  337
+    mS3Dparams.fmt = S3D_FORMAT_NONE;
  338
+    mS3Dparams.order = S3D_ORDER_LF;
  339
+    mS3Dparams.subsampling = S3D_SS_NONE;
  340
+    mS3Dparams.metadata = S3D_SEI_NONE;
  341
+    mVideoMode = VID_MODE_NORMAL;
  342
+#endif
  343
+
267 344
     reset();
268 345
 }
269 346
 
... ...
@@ -275,6 +352,9 @@ AwesomePlayer::~AwesomePlayer() {
275 352
     reset();
276 353
 
277 354
     mClient.disconnect();
  355
+#ifdef OMAP_ENHANCEMENT
  356
+    mExtractor.clear();
  357
+#endif
278 358
 }
279 359
 
280 360
 void AwesomePlayer::cancelPlayerEvents(bool keepBufferingGoing) {
... ...
@@ -304,6 +384,9 @@ status_t AwesomePlayer::setDataSource(
304 384
 
305 385
 status_t AwesomePlayer::setDataSource_l(
306 386
         const char *uri, const KeyedVector<String8, String8> *headers) {
  387
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  388
+    LOGD("setDataSource_l(%s)", uri);
  389
+#endif
307 390
     reset_l();
308 391
 
309 392
     mUri = uri;
... ...
@@ -345,6 +428,17 @@ status_t AwesomePlayer::setDataSource_l(
345 428
     if (extractor == NULL) {
346 429
         return UNKNOWN_ERROR;
347 430
     }
  431
+#ifdef OMAP_ENHANCEMENT
  432
+    sp<MetaData> fileMetadata = extractor->getMetaData();
  433
+    bool isAvailable = fileMetadata->findCString(kKeyMIMEType, &mExtractorType);
  434
+    if(isAvailable) {
  435
+        LOGV("%s:: ExtractorType %s", __FUNCTION__,  mExtractorType);
  436
+    }
  437
+    else {
  438
+        LOGV("%s:: ExtractorType not available", __FUNCTION__);
  439
+    }
  440
+    mExtractor = extractor;
  441
+#endif
348 442
 
349 443
     return setDataSource_l(extractor);
350 444
 }
... ...
@@ -381,7 +475,20 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
381 475
         CHECK(meta->findCString(kKeyMIMEType, &mime));
382 476
 
383 477
         if (!haveVideo && !strncasecmp(mime, "video/", 6)) {
  478
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  479
+           sp<MediaSource> mysource = extractor->getTrack(i);
  480
+            if(!strcasecmp(mime, MEDIA_MIMETYPE_VIDEO_WMV)){
  481
+                LOGV("ASF parser doesn't support parseSEIMessages()");
  482
+            }
  483
+            else {
  484
+                LOGV("Call parseSEIMessages()");
  485
+                mysource->parseSEIMessages(mS3Dparams);
  486
+            }
  487
+            LOGV("Call setVideoSource(mysource)");
  488
+           setVideoSource(mysource);
  489
+#else
384 490
             setVideoSource(extractor->getTrack(i));
  491
+#endif
385 492
             haveVideo = true;
386 493
         } else if (!haveAudio && !strncasecmp(mime, "audio/", 6)) {
387 494
             setAudioSource(extractor->getTrack(i));
... ...
@@ -439,6 +546,10 @@ void AwesomePlayer::reset_l() {
439 546
     mAudioTrack.clear();
440 547
     mVideoTrack.clear();
441 548
 
  549
+#ifdef OMAP_ENHANCEMENT
  550
+    mVideoMode = VID_MODE_NORMAL;
  551
+#endif
  552
+
442 553
     // Shutdown audio first, so that the respone to the reset request
443 554
     // appears to happen instantaneously as far as the user is concerned
444 555
     // If we did this later, audio would continue playing while we
... ...
@@ -457,12 +568,34 @@ void AwesomePlayer::reset_l() {
457 568
     delete mAudioPlayer;
458 569
     mAudioPlayer = NULL;
459 570
 
  571
+#ifndef OMAP_ENHANCEMENT
460 572
     mVideoRenderer.clear();
  573
+#endif
  574
+
  575
+#ifdef OMAP_ENHANCEMENT
  576
+    if (mBuffersWithRenderer.size()) {
  577
+        unsigned int i;
  578
+        unsigned int sz = mBuffersWithRenderer.size();
  579
+
  580
+        for(i = 0; i < sz; i++){
  581
+            mBuffersWithRenderer[i]->release();
  582
+        }
461 583
 
  584
+        for(i = 0; i < sz; i++){
  585
+            mBuffersWithRenderer.pop();
  586
+        }
  587
+    }
  588
+    // release reference in case it exists
  589
+    if (mFirstVideoBuffer != NULL) {
  590
+        mFirstVideoBuffer->release();
  591
+        mFirstVideoBuffer = NULL;
  592
+    }
  593
+#else
462 594
     if (mLastVideoBuffer) {
463 595
         mLastVideoBuffer->release();
464 596
         mLastVideoBuffer = NULL;
465 597
     }
  598
+#endif
466 599
 
467 600
     if (mVideoBuffer) {
468 601
         mVideoBuffer->release();
... ...
@@ -492,6 +625,10 @@ void AwesomePlayer::reset_l() {
492 625
         IPCThreadState::self()->flushCommands();
493 626
     }
494 627
 
  628
+#ifdef OMAP_ENHANCEMENT
  629
+    mVideoRenderer.clear();
  630
+#endif
  631
+
495 632
     mDurationUs = -1;
496 633
     mFlags = 0;
497 634
     mExtractorFlags = 0;
... ...
@@ -593,11 +730,18 @@ void AwesomePlayer::onBufferingUpdate() {
593 730
 
594 731
                 if ((mFlags & PLAYING) && !eos
595 732
                         && (cachedDataRemaining < kLowWaterMarkBytes)) {
  733
+#ifdef OMAP_ENHANCEMENT
  734
+                //if low cache duration is caused by a seek, wait audio callback to avoid MEDIA_SEEK_COMPLETE being lost.
  735
+                if (!mWatchForAudioSeekComplete) {
  736
+#endif
596 737
                     LOGI("cache is running low (< %d) , pausing.",
597 738
                          kLowWaterMarkBytes);
598 739
                     mFlags |= CACHE_UNDERRUN;
599 740
                     pause_l();
600 741
                     notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
  742
+#ifdef OMAP_ENHANCEMENT
  743
+                }
  744
+#endif
601 745
                 } else if (eos || cachedDataRemaining > kHighWaterMarkBytes) {
602 746
                     if (mFlags & CACHE_UNDERRUN) {
603 747
                         LOGI("cache has filled up (> %d), resuming.",
... ...
@@ -620,11 +764,18 @@ void AwesomePlayer::onBufferingUpdate() {
620 764
     if (getCachedDuration_l(&cachedDurationUs, &eos)) {
621 765
         if ((mFlags & PLAYING) && !eos
622 766
                 && (cachedDurationUs < kLowWaterMarkUs)) {
  767
+#ifdef OMAP_ENHANCEMENT
  768
+            //if low cache duration is caused by a seek, wait audio callback to avoid MEDIA_SEEK_COMPLETE being lost.
  769
+            if (!mWatchForAudioSeekComplete) {
  770
+#endif
623 771
             LOGI("cache is running low (%.2f secs) , pausing.",
624 772
                  cachedDurationUs / 1E6);
625 773
             mFlags |= CACHE_UNDERRUN;
626 774
             pause_l();
627 775
             notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
  776
+#ifdef OMAP_ENHANCEMENT
  777
+            }
  778
+#endif
628 779
         } else if (eos || cachedDurationUs > kHighWaterMarkUs) {
629 780
             if (mFlags & CACHE_UNDERRUN) {
630 781
                 LOGI("cache has filled up (%.2f secs), resuming.",
... ...
@@ -649,10 +800,12 @@ void AwesomePlayer::partial_reset_l() {
649 800
 
650 801
     mVideoRenderer.clear();
651 802
 
  803
+#ifndef OMAP_ENHANCEMENT
652 804
     if (mLastVideoBuffer) {
653 805
         mLastVideoBuffer->release();
654 806
         mLastVideoBuffer = NULL;
655 807
     }
  808
+#endif
656 809
 
657 810
     if (mVideoBuffer) {
658 811
         mVideoBuffer->release();
... ...
@@ -759,6 +912,35 @@ status_t AwesomePlayer::play_l() {
759 912
     mFlags |= PLAYING;
760 913
     mFlags |= FIRST_FRAME;
761 914
 
  915
+#ifdef OMAP_ENHANCEMENT
  916
+    if(mVideoSource != NULL) {
  917
+         if (mFirstVideoBuffer != NULL) {
  918
+                    mFirstVideoBuffer->release();
  919
+                    mFirstVideoBuffer = NULL;
  920
+        }
  921
+        mFirstVideoBufferResult = mVideoSource->read(&mFirstVideoBuffer);
  922
+        if (mFirstVideoBufferResult == INFO_FORMAT_CHANGED) {
  923
+            LOGV("First INFO_FORMAT_CHANGED!!!");
  924
+            LOGV("VideoSource signalled format change.");
  925
+            if (mVideoRenderer != NULL) {
  926
+                mVideoRendererIsPreview = false;
  927
+                initRenderer_l();
  928
+#ifdef OMAP_ENHANCEMENT
  929
+            if (mVideoRenderer != NULL) {
  930
+                // Share overlay buffers with video decoder.
  931
+                mVideoSource->setBuffers(mVideoRenderer->getBuffers(), true);
  932
+            }
  933
+#endif
  934
+            }
  935
+            CHECK(mFirstVideoBuffer == NULL);
  936
+            mFirstVideoBufferResult = OK;
  937
+            mIsFirstVideoBuffer = false;
  938
+        } 
  939
+       else {
  940
+            mIsFirstVideoBuffer = true;
  941
+        }
  942
+}
  943
+#endif
762 944
     bool deferredAudioSeek = false;
763 945
 
764 946
     if (mAudioSource != NULL) {
... ...
@@ -777,7 +959,12 @@ status_t AwesomePlayer::play_l() {
777 959
                     mAudioPlayer = NULL;
778 960
 
779 961
                     mFlags &= ~(PLAYING | FIRST_FRAME);
780  
-
  962
+#ifdef OMAP_ENHANCEMENT
  963
+                    if (mFirstVideoBuffer) {
  964
+                        mFirstVideoBuffer->release();
  965
+                        mFirstVideoBuffer = NULL;
  966
+                    }
  967
+#endif
781 968
                     return err;
782 969
                 }
783 970
 
... ...
@@ -789,7 +976,25 @@ status_t AwesomePlayer::play_l() {
789 976
                 mWatchForAudioEOS = true;
790 977
             }
791 978
         } else {
  979
+#ifdef OMAP_ENHANCEMENT
  980
+            if (!mSeeking || mVideoSource == NULL) {
  981
+               // Resume when video is not present or when
  982
+               // not seeking and flush the sink so buffer from
  983
+                //previous position is not heard
  984
+                if(mSeeking){
  985
+                    if(mAudioSink.get() != NULL){
  986
+                        mAudioSink->flush();
  987
+                    }
  988
+                }
  989
+                mAudioPlayer->resume();
  990
+            } else {
  991
+                // when seeking it is too early to resume
  992
+                // as audio has not seek yet
  993
+                mFlags |= HOLD_TO_RESUME;
  994
+            }
  995
+#else
792 996
             mAudioPlayer->resume();
  997
+#endif
793 998
         }
794 999
     }
795 1000
 
... ...
@@ -831,7 +1036,41 @@ status_t AwesomePlayer::initRenderer_l() {
831 1036
     CHECK(meta->findCString(kKeyDecoderComponent, &component));
832 1037
     CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
833 1038
     CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
834  
-
  1039
+#ifdef OMAP_ENHANCEMENT
  1040
+#ifdef TARGET_OMAP4
  1041
+    CHECK(meta->findInt32(kKeyWidth, &mVideoWidth));
  1042
+    CHECK(meta->findInt32(kKeyHeight, &mVideoHeight));
  1043
  1044
+    if(!(meta->findInt32(kKeyPaddedWidth, &decodedWidth))) {
  1045
+       CHECK(meta->findInt32(kKeyWidth, &decodedWidth));
  1046
+    }
  1047
+    if(!(meta->findInt32(kKeyPaddedHeight, &decodedHeight))) {
  1048
+       CHECK(meta->findInt32(kKeyHeight, &decodedHeight));
  1049
+    }
  1050
+#endif
  1051
+    LOGD(" initRenderer_l %dx%d",decodedWidth,decodedHeight );
  1052
+    LOGD(" initRenderer_l %dx%d",mVideoWidth,mVideoHeight );
  1053
+    if (mVideoRenderer != NULL) {
  1054
+        //we cant destroy overlay based renderer here,as the overlay has 2 handles 
  1055
+        //(1) from media server process (the current process)
  1056
+        //(2) from surface flinger process.
  1057
+        // Hence, we have to resize the renderer for new dimensions than dstroying and  
  1058
+        // re-creating
  1059
+
  1060
+        uint32_t outputBufferCnt = -1;
  1061
+        outputBufferCnt = mVideoSource->getNumofOutputBuffers();
  1062
+        LOGD("Codec Recommended outputBuffer count after portreconfig %d",outputBufferCnt);
  1063
+        render_resize_params resize_params;
  1064
+        resize_params.decoded_width = decodedWidth;
  1065
+        resize_params.decoded_height = decodedHeight;
  1066
+        resize_params.buffercount = outputBufferCnt;
  1067
+        resize_params.display_width = mVideoWidth;
  1068
+        resize_params.display_height = mVideoHeight;
  1069
+
  1070
+        mVideoRenderer->resizeRenderer((void*)(&resize_params));
  1071
+        return 0;
  1072
+    } 
  1073
+#endif
835 1074
     int32_t rotationDegrees;
836 1075
     if (!mVideoTrack->getFormat()->findInt32(
837 1076
                 kKeyRotation, &rotationDegrees)) {
... ...
@@ -840,6 +1079,11 @@ status_t AwesomePlayer::initRenderer_l() {
840 1079
 
841 1080
     mVideoRenderer.clear();
842 1081
 
  1082
+#if defined( OMAP_ENHANCEMENT) && !defined(TARGET_OMAP4)
  1083
+    // Initializing S3D flag, to be passed by higher layer
  1084
+    int isS3D =0;
  1085
+#endif
  1086
+
843 1087
     // Must ensure that mVideoRenderer's destructor is actually executed
844 1088
     // before creating a new one.
845 1089
     IPCThreadState::self()->flushCommands();
... ...
@@ -849,6 +1093,44 @@ status_t AwesomePlayer::initRenderer_l() {
849 1093
         // therefore they require a remote IOMXRenderer that knows how
850 1094
         // to display them.
851 1095
 
  1096
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1097
+        //initialize the codec recommended buffers to -1
  1098
+        int32_t outputBufferCnt = -1;
  1099
+        outputBufferCnt = mVideoSource->getNumofOutputBuffers();
  1100
+        LOGD("Codec Recommended outputBuffer count %d",outputBufferCnt);
  1101
+
  1102
+        sp<IOMXRenderer> native =
  1103
+            mClient.interface()->createRenderer(
  1104
+                    mISurface, component,
  1105
+                    (OMX_COLOR_FORMATTYPE)format,
  1106
+                    decodedWidth, decodedHeight,
  1107
+                    mVideoWidth, mVideoHeight,
  1108
+                    rotationDegrees, mS3Dparams.active, outputBufferCnt);
  1109
+
  1110
+        if (native == NULL) {
  1111
+            return NO_INIT;
  1112
+        }
  1113
+
  1114
+        mVideoRenderer = new AwesomeRemoteRenderer(native);
  1115
+
  1116
+#elif defined(OMAP_ENHANCEMENT)
  1117
+        int32_t outputBufferCnt = -1;
  1118
+
  1119
+        sp<IOMXRenderer> native =
  1120
+            mClient.interface()->createRenderer(
  1121
+                    mISurface, component,
  1122
+                    (OMX_COLOR_FORMATTYPE)format,
  1123
+                    decodedWidth, decodedHeight,
  1124
+                    mVideoWidth, mVideoHeight,
  1125
+                    rotationDegrees, isS3D, outputBufferCnt);
  1126
+
  1127
+        if (native == NULL) {
  1128
+            return NO_INIT;
  1129
+        }
  1130
+
  1131
+        mVideoRenderer = new AwesomeRemoteRenderer(native);
  1132
+
  1133
+#else
852 1134
         sp<IOMXRenderer> native =
853 1135
             mClient.interface()->createRenderer(
854 1136
                     mISurface, component,
... ...
@@ -862,6 +1144,18 @@ status_t AwesomePlayer::initRenderer_l() {
862 1144
         }
863 1145
 
864 1146
         mVideoRenderer = new AwesomeRemoteRenderer(native);
  1147
+#endif
  1148
+#ifdef OMAP_ENHANCEMENT
  1149
+            if (!strncmp("OMX.TI", component, 6)) {
  1150
+#if defined(TARGET_OMAP4)
  1151
+                if(mS3Dparams.active)
  1152
+                    mVideoRenderer->set_s3d_frame_layout(mS3Dparams.mode ,mS3Dparams.fmt ,mS3Dparams.order, mS3Dparams.subsampling);
  1153
+#endif
  1154
+                mBufferReleaseCallbackSet = mVideoRenderer->setCallback(releaseRenderedBufferCallback, this);
  1155
+                mVideoRenderer->setCallback(releaseRenderedBufferCallback, this);  
  1156
+            }
  1157
+#endif
  1158
+
865 1159
     } else {
866 1160
         // Other decoders are instantiated locally and as a consequence
867 1161
         // allocate their buffers in local address space.
... ...
@@ -890,6 +1184,12 @@ status_t AwesomePlayer::pause_l(bool at_eos) {
890 1184
         return OK;
891 1185
     }
892 1186
 
  1187
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  1188
+    if (mVideoSource != NULL) {
  1189
+        // Indicating to codec that Pause button pressed
  1190
+        mVideoSource->pause();
  1191
+    }
  1192
+#endif
893 1193
     cancelPlayerEvents(true /* keepBufferingGoing */);
894 1194
 
895 1195
     if (mAudioPlayer != NULL) {
... ...
@@ -1053,11 +1353,86 @@ status_t AwesomePlayer::initAudioDecoder() {
1053 1353
 
1054 1354
     if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) {
1055 1355
         mAudioSource = mAudioTrack;
  1356
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1357
+    }
  1358
+    else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_WMA)) {
  1359
+        const char *componentName  = "OMX.ITTIAM.WMA.decode";
  1360
+        mAudioSource = OMXCodec::Create(
  1361
+        mClient.interface(), mAudioTrack->getFormat(),
  1362
+        false,
  1363
+        mAudioTrack, componentName);
  1364
+        if (mAudioSource == NULL) {
  1365
+            LOGE("Failed to create OMX component for WMA codec");
  1366
+        }
  1367
+#endif
1056 1368
     } else {
  1369
+#ifdef OMAP_ENHANCEMENT
  1370
+        if (mVideoWidth*mVideoHeight > MAX_RESOLUTION) {
  1371
+         // video is launched first, so these capablities are known
  1372
+         // audio can be selected accordingly
  1373
+         // TODO: extend this to a method that can include more
  1374
+         // capabilities to evaluate
  1375
+
  1376
+#ifdef TARGET_OMAP4
  1377
+            //for OMAP4 720p,1080p videos, lets stick to OMX.PV audio codecs
  1378
+            mAudioSource = OMXCodec::Create(
  1379
+                    mClient.interface(), mAudioTrack->getFormat(),
  1380
+                    false, // createEncoder
  1381
+                    mAudioTrack);
  1382
+#else
  1383
+        bool isIttiamAudioCodecRequired = false;
  1384
+        bool is720PCodecRequired = (mVideoWidth*mVideoHeight > MAX_RESOLUTION) ? true : false;
  1385
+
  1386
+        if (true == is720PCodecRequired) {
  1387
+            isIttiamAudioCodecRequired = true;
  1388
+        }
  1389
+        if (true == isIttiamAudioCodecRequired){
  1390
+
  1391
+         // video is launched first, so these capablities are known
  1392
+         // audio can be selected accordingly
  1393
+         // TODO: extend this to a method that can include more
  1394
+         // capabilities to evaluate
  1395
+
  1396
+            const char *componentName;
  1397
+            if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AAC)) {
  1398
+                componentName = "OMX.ITTIAM.AAC.decode";
  1399
+
  1400
+            mAudioSource = OMXCodec::Create(
  1401
+                    mClient.interface(), mAudioTrack->getFormat(),
  1402
+                    false, // createEncoder
  1403
+                        mAudioTrack, componentName);
  1404
+            }
  1405
+            else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_WMA)) {
  1406
+                componentName = "OMX.ITTIAM.WMA.decode";
  1407
+
  1408
+                mAudioSource = OMXCodec::Create(
  1409
+                        mClient.interface(), mAudioTrack->getFormat(),
  1410
+                        false,
  1411
+                        mAudioTrack, componentName);
  1412
+
  1413
+            }
  1414
+            else {
  1415
+                componentName = "NoComponentAvailable";
  1416
+
  1417
+                mAudioSource = OMXCodec::Create(
  1418
+                        mClient.interface(), mAudioTrack->getFormat(),
  1419
+                        false,
  1420
+                        mAudioTrack);
  1421
+            }
  1422
+        }
  1423
+#endif
  1424
+        } else {
  1425
+            mAudioSource = OMXCodec::Create(
  1426
+                    mClient.interface(), mAudioTrack->getFormat(),
  1427
+                    false, // createEncoder
  1428
+                    mAudioTrack);
  1429
+        }
  1430
+#else
1057 1431
         mAudioSource = OMXCodec::Create(
1058 1432
                 mClient.interface(), mAudioTrack->getFormat(),
1059 1433
                 false, // createEncoder
1060 1434
                 mAudioTrack);
  1435
+#endif
1061 1436
     }
1062 1437
 
1063 1438
     if (mAudioSource != NULL) {
... ...
@@ -1091,12 +1466,136 @@ void AwesomePlayer::setVideoSource(sp<MediaSource> source) {
1091 1466
     mVideoTrack = source;
1092 1467
 }
1093 1468
 
  1469
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  1470
+/*
  1471
+  * Dynamically update S3D display driver based on framelayout configuration changes
  1472
+  * sent by Codec as OMX metadata
  1473
+  */
  1474
+void AwesomePlayer::updateS3DRenderer()
  1475
+{
  1476
+
  1477
+    status_t ret = NO_ERROR;
  1478
+    void *OMXplaformPrivate;
  1479
+    OMX_OTHER_EXTRADATATYPE *extraData;
  1480
+    int32_t lCounter = 0;
  1481
+
  1482
+    CHECK_EQ(mVideoBuffer->meta_data()->findPointer(kKeyPlatformPrivate, &OMXplaformPrivate), true);
  1483
+
  1484
+    if ( ((OMX_TI_PLATFORMPRIVATE *)OMXplaformPrivate)->nMetaDataSize <= 0 || ((OMX_TI_PLATFORMPRIVATE *) OMXplaformPrivate)->pMetaDataBuffer == NULL)
  1485
+    {
  1486
+        LOGV("No MetaData in this buffer \n");
  1487
+        return;
  1488
+    }
  1489
+
  1490
+    do
  1491
+    {
  1492
+        extraData = (OMX_OTHER_EXTRADATATYPE *) (((OMX_TI_PLATFORMPRIVATE *) OMXplaformPrivate)->pMetaDataBuffer + lCounter);
  1493
+        switch( extraData-> eType)
  1494
+        {
  1495
+            case OMX_TI_SEIinfo2004Frame1:
  1496
+            case OMX_TI_SEIinfo2004Frame2:
  1497
+            {
  1498
+                if(configSEI2004Infos(extraData))
  1499
+                    //update S3D driver dynamic configuration parameters
  1500
+                    mVideoRenderer->set_s3d_frame_layout(mS3Dparams.mode ,mS3Dparams.fmt ,mS3Dparams.order, mS3Dparams.subsampling);
  1501
+                return;
  1502
+                break;
  1503
+            }
  1504
+            case OMX_TI_SEIinfo2010Frame1:
  1505
+            case OMX_TI_SEIinfo2010Frame2:
  1506
+            {
  1507
+                if(configSEI2010Infos(extraData))
  1508
+                    //update S3D driver dynamic configuration parameters
  1509
+                    mVideoRenderer->set_s3d_frame_layout(mS3Dparams.mode ,mS3Dparams.fmt ,mS3Dparams.order, mS3Dparams.subsampling);
  1510
+                return;
  1511
+                break;
  1512
+            }
  1513
+            default:
  1514
+            {
  1515
+                LOGV("No SEI meta data \n");
  1516
+                break;
  1517
+            }
  1518
+        }
  1519
+        lCounter += extraData->nSize;
  1520
+    }while ((lCounter < ( (OMX_TI_PLATFORMPRIVATE *)OMXplaformPrivate)->nMetaDataSize ) && (extraData-> eType !=0 ));
  1521
+
  1522
+}
  1523
+
  1524
+bool AwesomePlayer::configSEI2004Infos(OMX_OTHER_EXTRADATATYPE *extraData)
  1525
+{
  1526
+    if(mS3Dparams.metadata != S3D_SEI_STEREO_INFO_PROGRESSIVE || mS3Dparams.metadata != S3D_SEI_STEREO_INFO_INTERLACED)
  1527
+        LOGV("SEI buffer configuration changed \n");
  1528
+
  1529
+    OMX_TI_STEREODECINFO * pstereoDecInfo;
  1530
+    pstereoDecInfo = (OMX_TI_STEREODECINFO *) (extraData->data);
  1531
+
  1532
+    if(sizeof(OMX_TI_STEREODECINFO) == extraData->nDataSize)
  1533
+    {
  1534
+        if(pstereoDecInfo->nFieldViewsFlag)
  1535
+        {
  1536
+            if(pstereoDecInfo->nTopFieldIsLeftViewFlag)
  1537
+                mS3Dparams.order = S3D_ORDER_LF;
  1538
+            else
  1539
+                mS3Dparams.order = S3D_ORDER_RF;
  1540
+        }
  1541
+        else
  1542
+        {
  1543
+             if(pstereoDecInfo->nCurrentFrameIsLeftViewFlag)
  1544
+                mS3Dparams.order = S3D_ORDER_LF;
  1545
+            else
  1546
+                mS3Dparams.order = S3D_ORDER_RF;
  1547
+        }
  1548
+        return true;
  1549
+    }
  1550
+    return false;
  1551
+}
  1552
+
  1553
+bool AwesomePlayer::configSEI2010Infos(OMX_OTHER_EXTRADATATYPE *extraData)
  1554
+{
  1555
+    if(mS3Dparams.metadata != S3D_SEI_STEREO_FRAME_PACKING)
  1556
+        LOGV("SEI buffer configuration changed \n");
  1557
+
  1558
+    OMX_TI_FRAMEPACKINGDECINFO * pframePackingDecInfo;
  1559
+    pframePackingDecInfo = (OMX_TI_FRAMEPACKINGDECINFO *) (extraData->data);
  1560
+
  1561
+    if(sizeof(OMX_TI_FRAMEPACKINGDECINFO) == extraData->nDataSize)
  1562
+    {
  1563
+        if(pframePackingDecInfo->nFramePackingArrangementCancelFlag)
  1564
+        {
  1565
+            set_frame_packing_arrangement_type(pframePackingDecInfo->nFramePackingArrangementType, mS3Dparams.fmt, mS3Dparams.subsampling);
  1566
+            if(pframePackingDecInfo->nContentInterpretationType)
  1567
+                mS3Dparams.order = S3D_ORDER_LF;
  1568
+            else
  1569
+                mS3Dparams.order = S3D_ORDER_RF;
  1570
+            return true;
  1571
+        }
  1572
+    }
  1573
+    return false;
  1574
+}
  1575
+#endif
  1576
+
1094 1577
 status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
  1578
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1579
+
  1580
+    //Call config parser to update profile,level,interlaced,reference frame data
  1581
+    updateMetaData(mVideoTrack->getFormat());
  1582
+
  1583
+    int32_t isInterlaced = false;
  1584
+    mVideoTrack->getFormat()->findInt32(kKeyVideoInterlaced, &isInterlaced);
  1585
+
  1586
+    mVideoSource = OMXCodec::Create(
  1587
+            mClient.interface(), mVideoTrack->getFormat(),
  1588
+            false, // createEncoder
  1589
+            mVideoTrack,
  1590
+            NULL,
  1591
+            (flags | isInterlaced)?OMXCodec::kPreferInterlacedOutputContent:0);
  1592
+#else
1095 1593
     mVideoSource = OMXCodec::Create(
1096 1594
             mClient.interface(), mVideoTrack->getFormat(),
1097 1595
             false, // createEncoder
1098 1596
             mVideoTrack,
1099 1597
             NULL, flags);
  1598
+#endif
1100 1599
 
1101 1600
     if (mVideoSource != NULL) {
1102 1601
         int64_t durationUs;
... ...
@@ -1110,12 +1609,15 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
1110 1609
         CHECK(mVideoTrack->getFormat()->findInt32(kKeyWidth, &mVideoWidth));
1111 1610
         CHECK(mVideoTrack->getFormat()->findInt32(kKeyHeight, &mVideoHeight));
1112 1611
 
  1612
+#ifndef OMAP_ENHANCEMENT
1113 1613
         status_t err = mVideoSource->start();
1114 1614
 
1115 1615
         if (err != OK) {
1116 1616
             mVideoSource.clear();
1117 1617
             return err;
1118 1618
         }
  1619
+#endif
  1620
+
1119 1621
     }
1120 1622
 
1121 1623
     return mVideoSource != NULL ? OK : UNKNOWN_ERROR;
... ...
@@ -1157,11 +1659,17 @@ void AwesomePlayer::onVideoEvent() {
1157 1659
     mVideoEventPending = false;
1158 1660
 
1159 1661
     if (mSeeking) {
  1662
+#ifdef OMAP_ENHANCEMENT
  1663
+        if (mFirstVideoBuffer) {
  1664
+            mFirstVideoBuffer->release();
  1665
+            mFirstVideoBuffer = NULL;
  1666
+        }
  1667
+#else
1160 1668
         if (mLastVideoBuffer) {
1161 1669
             mLastVideoBuffer->release();
1162 1670
             mLastVideoBuffer = NULL;
1163 1671
         }
1164  
-
  1672
+#endif
1165 1673
         if (mVideoBuffer) {
1166 1674
             mVideoBuffer->release();
1167 1675
             mVideoBuffer = NULL;
... ...
@@ -1187,12 +1695,33 @@ void AwesomePlayer::onVideoEvent() {
1187 1695
         MediaSource::ReadOptions options;
1188 1696
         if (mSeeking) {
1189 1697
             LOGV("seeking to %lld us (%.2f secs)", mSeekTimeUs, mSeekTimeUs / 1E6);
1190  
-
  1698
+#ifdef OMAP_ENHANCEMENT
  1699
+            if (mIsFirstVideoBuffer) {
  1700
+                if (mFirstVideoBuffer != NULL) {
  1701
+                    mFirstVideoBuffer->release();
  1702
+                    mFirstVideoBuffer = NULL;
  1703
+                }
  1704
+                mIsFirstVideoBuffer = false;
  1705
+            }
  1706
+#endif
1191 1707
             options.setSeekTo(
1192 1708
                     mSeekTimeUs, MediaSource::ReadOptions::SEEK_CLOSEST_SYNC);
1193 1709
         }
1194 1710
         for (;;) {
  1711
+#ifdef OMAP_ENHANCEMENT
  1712
+            status_t err;
  1713
+            if (mIsFirstVideoBuffer) {
  1714
+                mVideoBuffer = mFirstVideoBuffer;
  1715
+                mFirstVideoBuffer = NULL;
  1716
+                err = mFirstVideoBufferResult;
  1717
+
  1718
+                mIsFirstVideoBuffer = false;
  1719
+            } else {
  1720
+                err = mVideoSource->read(&mVideoBuffer, &options);
  1721
+            }
  1722
+#else
1195 1723
             status_t err = mVideoSource->read(&mVideoBuffer, &options);
  1724
+#endif
1196 1725
             options.clearSeekTo();
1197 1726
 
1198 1727
             if (err != OK) {
... ...
@@ -1203,10 +1732,40 @@ void AwesomePlayer::onVideoEvent() {
1203 1732
 
1204 1733
                     if (mVideoRenderer != NULL) {
1205 1734
                         mVideoRendererIsPreview = false;
1206  
-                        err = initRenderer_l();
  1735
+#ifdef OMAP_ENHANCEMENT
  1736
+                        if (mBuffersWithRenderer.size()) {
  1737
+                            unsigned int i;
  1738
+                            unsigned int sz = mBuffersWithRenderer.size();
  1739
+
  1740
+                            for(i = 0; i < sz; i++){
  1741
+                                mBuffersWithRenderer[i]->release();
  1742
+                            }
  1743
+
  1744
+                            for(i = 0; i < sz; i++){
  1745
+                                mBuffersWithRenderer.pop();
  1746
+                            }
  1747
+                        }
1207 1748
 
  1749
+                        if (mFirstVideoBuffer != NULL) {
  1750
+                            mFirstVideoBuffer->release();
  1751
+                            mFirstVideoBuffer = NULL;
  1752
+                        }
  1753
+                        if (mVideoBuffer) {
  1754
+                            mVideoBuffer->release();
  1755
+                            mVideoBuffer = NULL;
  1756
+                        }
  1757
+#endif
  1758
+
  1759
+                        err = initRenderer_l();
1208 1760
                         if (err == OK) {
1209  
-                            continue;
  1761
+#ifdef OMAP_ENHANCEMENT
  1762
+                        if (mVideoRenderer != NULL) {
  1763
+                            // Share overlay buffers with video decoder.
  1764
+                            mVideoSource->setBuffers(mVideoRenderer->getBuffers(), true);
  1765
+                        }
  1766
+                        postVideoEvent_l(0);
  1767
+#endif
  1768
+                            return;
1210 1769
                         }
1211 1770
 
1212 1771
                         // fall through
... ...
@@ -1280,22 +1839,50 @@ void AwesomePlayer::onVideoEvent() {
1280 1839
         // and we'll play incoming video as fast as we get it.
1281 1840
         latenessUs = 0;
1282 1841
     }
  1842
+#ifdef OMAP_ENHANCEMENT
  1843
+    LOGV("%s::%d: (latenessUs= %lld) = ((nowUs= %lld) - (timeUs=%lld))", __FUNCTION__, __LINE__, latenessUs, nowUs, timeUs);
1283 1844
 
  1845
+    if (latenessUs > 50000) {
  1846
+        // We're more than 50ms late.
  1847
+
  1848
+        /* Trace to detect frame drops */
  1849
+        LOGV("Frame dropped - lateness (%lld - %lld = %lld uS)",nowUs,timeUs,latenessUs);
  1850
+
  1851
+#else
1284 1852
     if (latenessUs > 40000) {
1285 1853
         // We're more than 40ms late.
  1854
+#endif
1286 1855
         LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6);
1287 1856
 
1288 1857
         mVideoBuffer->release();
1289 1858
         mVideoBuffer = NULL;
1290  
-
  1859
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1860
+        postVideoEvent_l(0);
  1861
+#else
1291 1862
         postVideoEvent_l();
  1863
+#endif
1292 1864
         return;
1293 1865
     }
1294  
-
  1866
+#if defined(OMAP_ENHANCEMENT) && !defined(TARGET_OMAP4)
  1867
+    if (latenessUs < -100000) {
  1868
+        // We're more than 100ms early.
  1869
+        LOGV("%s::%d: Frame is early than 100ms: %lld", __FUNCTION__, __LINE__, latenessUs);
  1870
+        LOGV("%s::%d: postVideoEvent_l(10000)", __FUNCTION__, __LINE__);
  1871
+#else
1295 1872
     if (latenessUs < -10000) {
1296 1873
         // We're more than 10ms early.
  1874
+#endif
1297 1875
 
  1876
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1877
+        //There is no need to poll for 10 msec
  1878
+        //This going to increase the MHz on ARM. Try to come back
  1879
+        //when we need to exactly post. Need to do a mod for 100 msec
  1880
+        //so that while seeking the video frame doesnt wait for lateness
  1881
+        //which can be a huge delay. This will result like a hang
  1882
+        postVideoEvent_l((latenessUs * -1) % 100000);
  1883
+#else
1298 1884
         postVideoEvent_l(10000);
  1885
+#endif
1299 1886
         return;
1300 1887
     }
1301 1888
 
... ...
@@ -1310,21 +1897,56 @@ void AwesomePlayer::onVideoEvent() {
1310 1897
             mFlags |= VIDEO_AT_EOS;
1311 1898
             postStreamDoneEvent_l(err);
1312 1899
             return;
  1900
+        } else {
  1901
+#ifdef OMAP_ENHANCEMENT
  1902
+        if (mVideoRenderer != NULL) {
  1903
+            // Share overlay buffers with video decoder.
  1904
+            mVideoSource->setBuffers(mVideoRenderer->getBuffers(), true);
1313 1905
         }
  1906
+#endif
  1907
+    }
1314 1908
     }
1315 1909
 
  1910
+#ifdef OMAP_ENHANCEMENT
  1911
+    /*the buffer needs to be pushed to local database before calling render.
  1912
+    * This is required to release the buffer back to Video source if the
  1913
+    * buffer can't be queued to the DSS
  1914
+    */
  1915
+    mBuffersWithRenderer.push(mVideoBuffer);
  1916
+#endif
  1917
+
1316 1918
     if (mVideoRenderer != NULL) {
  1919
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  1920
+    int32_t isExtraData = 0;
  1921
+    if(mS3Dparams.active && mVideoBuffer->meta_data()->findInt32(kKeyIsExtraData, &isExtraData))
  1922
+            updateS3DRenderer();
  1923
+#endif
1317 1924
         mVideoRenderer->render(mVideoBuffer);
1318 1925
     }
1319 1926
 
  1927
+#ifdef OMAP_ENHANCEMENT
  1928
+    if ((!mBufferReleaseCallbackSet)  && (mBuffersWithRenderer.size())){
  1929
+        mBuffersWithRenderer[0]->release();
  1930
+        mBuffersWithRenderer.pop();
  1931
+    }
  1932
+#else
1320 1933
     if (mLastVideoBuffer) {
1321 1934
         mLastVideoBuffer->release();
1322 1935
         mLastVideoBuffer = NULL;
1323 1936
     }
1324 1937
     mLastVideoBuffer = mVideoBuffer;
1325  
-    mVideoBuffer = NULL;
  1938
+#endif
1326 1939
 
  1940
+    mVideoBuffer = NULL;
  1941
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1942
+    // No need to trigger the poll after 10 msec which is default value
  1943
+    // This is causing a jerk in AV sync. We can trigger a 0 msec and accurate
  1944
+    // wait which will allow more ARM sleep time
  1945
+    postVideoEvent_l(0);
  1946
+#else
1327 1947
     postVideoEvent_l();
  1948
+#endif
  1949
+
1328 1950
 }
1329 1951
 
1330 1952
 void AwesomePlayer::postVideoEvent_l(int64_t delayUs) {
... ...
@@ -1664,6 +2286,17 @@ status_t AwesomePlayer::finishSetDataSource_l() {
1664 2286
     if (extractor == NULL) {
1665 2287
         return UNKNOWN_ERROR;
1666 2288
     }
  2289
+#ifdef OMAP_ENHANCEMENT
  2290
+    sp<MetaData> fileMetadata = extractor->getMetaData();
  2291
+    bool isAvailable = fileMetadata->findCString(kKeyMIMEType, &mExtractorType);
  2292
+    if(isAvailable) {
  2293
+        LOGV("%s:: ExtractorType %s", __FUNCTION__,  mExtractorType);
  2294
+    }
  2295
+    else {
  2296
+        LOGV("%s:: ExtractorType not available", __FUNCTION__);
  2297
+    }
  2298
+    mExtractor = extractor;
  2299
+#endif
1667 2300
 
1668 2301
     return setDataSource_l(extractor);
1669 2302
 }
... ...
@@ -1708,7 +2341,24 @@ void AwesomePlayer::onPrepareAsyncEvent() {
1708 2341
 
1709 2342
     if (mVideoTrack != NULL && mVideoSource == NULL) {
1710 2343
         status_t err = initVideoDecoder();
  2344
+#ifdef OMAP_ENHANCEMENT
  2345
+            if (err == OK){
  2346
+                if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
  2347
+                    mVideoRendererIsPreview = false;
  2348
+                    initRenderer_l();
  2349
+                    if (mVideoRenderer != NULL) {
  2350
+                        // Share overlay buffers with video decoder.
  2351
+                        mVideoSource->setBuffers(mVideoRenderer->getBuffers(), false);
  2352
+                    }
  2353
+                }
1711 2354
 
  2355
+                err = mVideoSource->start();
  2356
+                if (err != OK) {
  2357
+                    mVideoSource.clear();
  2358
+                    //Subsequent error handling will take of returning.
  2359
+                }
  2360
+            }
  2361
+#endif
1712 2362
         if (err != OK) {
1713 2363
             abortPrepare(err);
1714 2364
             return;
... ...
@@ -1769,7 +2419,11 @@ status_t AwesomePlayer::suspend() {
1769 2419
     Mutex::Autolock autoLock(mLock);
1770 2420
 
1771 2421
     if (mSuspensionState != NULL) {
  2422
+#ifdef OMAP_ENHANCEMENT
  2423
+        if (mBuffersWithRenderer.size() == 0) {
  2424
+#else
1772 2425
         if (mLastVideoBuffer == NULL) {
  2426
+#endif
1773 2427
             //go into here if video is suspended again
1774 2428
             //after resuming without being played between
1775 2429
             //them
... ...
@@ -1804,20 +2458,50 @@ status_t AwesomePlayer::suspend() {
1804 2458
     state->mFlags = mFlags & (PLAYING | AUTO_LOOPING | LOOPING | AT_EOS);
1805 2459
     getPosition(&state->mPositionUs);
1806 2460
 
  2461
+#ifdef OMAP_ENHANCEMENT
  2462
+#ifdef TARGET_OMAP4
  2463
+    // FIXME: This caching of last frame crashes in L27x. Not used anyway, but check why.
  2464
+    // This should be removed after fill the code for (mBufferWithRenderer.size() > 0)
  2465
+    if (0) {
  2466
+#else /* TARGET_OMAP3 */
  2467
+    // Currently this code is used only by OMAP3.
  2468
+    if (mBuffersWithRenderer.size()) {
  2469
+#endif
  2470
+        size_t size = mBuffersWithRenderer[0]->range_length();
  2471
+#else
1807 2472
     if (mLastVideoBuffer) {
1808 2473
         size_t size = mLastVideoBuffer->range_length();
1809  
-
  2474
+#endif
1810 2475
         if (size) {
1811 2476
             int32_t unreadable;
  2477
+#ifdef OMAP_ENHANCEMENT
  2478
+            if (!mBuffersWithRenderer[0]->meta_data()->findInt32(
  2479
+                        kKeyIsUnreadable, &unreadable)
  2480
+                    || unreadable == 0) {
  2481
+                state->mLastVideoFrameSize = size;
  2482
+                state->mLastVideoFrame = malloc(size);
  2483
+
  2484
+#ifdef TARGET_OMAP4
  2485
+                // FIXME: here for OMAP4
  2486
+                // Please fill this part for OMAP4
  2487
+#else
  2488
+                memcpy(state->mLastVideoFrame,
  2489
+                   (const uint8_t *)mBuffersWithRenderer[0]->data()
  2490
+                        + mBuffersWithRenderer[0]->range_offset(),
  2491
+                   size);
  2492
+#endif
  2493
+#else
1812 2494
             if (!mLastVideoBuffer->meta_data()->findInt32(
1813 2495
                         kKeyIsUnreadable, &unreadable)
1814 2496
                     || unreadable == 0) {
1815 2497
                 state->mLastVideoFrameSize = size;
1816 2498
                 state->mLastVideoFrame = malloc(size);
  2499
+
1817 2500
                 memcpy(state->mLastVideoFrame,
1818  
-                       (const uint8_t *)mLastVideoBuffer->data()
1819  
-                            + mLastVideoBuffer->range_offset(),
1820  
-                       size);
  2501
+                   (const uint8_t *)mLastVideoBuffer->data()
  2502
+                        + mLastVideoBuffer->range_offset(),
  2503
+                   size);
  2504
+#endif
1821 2505
 
1822 2506
                 state->mVideoWidth = mVideoWidth;
1823 2507
                 state->mVideoHeight = mVideoHeight;
... ...
@@ -1890,6 +2574,10 @@ status_t AwesomePlayer::resume() {
1890 2574
 
1891 2575
         ((AwesomeLocalRenderer *)mVideoRenderer.get())->render(
1892 2576
                 state->mLastVideoFrame, state->mLastVideoFrameSize);
  2577
+#ifdef OMAP_ENHANCEMENT
  2578
+        mVideoRenderer.clear();
  2579
+        mVideoRenderer = NULL;
  2580
+#endif
1893 2581
     }
1894 2582
 
1895 2583
     if (state->mFlags & PLAYING) {
... ...
@@ -1913,6 +2601,46 @@ void AwesomePlayer::postAudioEOS() {
1913 2601
 void AwesomePlayer::postAudioSeekComplete() {
1914 2602
     postCheckAudioStatusEvent_l();
1915 2603
 }
  2604
+#ifdef OMAP_ENHANCEMENT
  2605
+void AwesomePlayer::releaseRenderedBuffer(const sp<IMemory>& mem){
  2606
+
  2607
+    bool buffer_released = false;
  2608
+    unsigned int i = 0;
  2609
+
  2610
+    for(i = 0; i < mBuffersWithRenderer.size(); i++){
  2611
+        if (mBuffersWithRenderer[i]->data() == mem->pointer()){
  2612
+            mBuffersWithRenderer[i]->release();
  2613
+            mBuffersWithRenderer.removeAt(i);
  2614
+            buffer_released = true;
  2615
+            break;
  2616
+        }
  2617
+    }
  2618
+
  2619
+    if (buffer_released == false)
  2620
+        LOGD("Something wrong... Overlay returned wrong buffer address(%p). This message is harmless if you just did a seek.", mem->pointer());
  2621
+}
  2622
+
  2623
+
  2624
+status_t AwesomePlayer::requestVideoCloneMode(bool enable) {
  2625
+    if (enable)
  2626
+    {
  2627
+        if ((mVideoMode != VID_MODE_CLONE) && (mVideoRenderer != NULL)) {
  2628
+            mVideoMode = VID_MODE_CLONE;
  2629
+            mVideoRenderer->requestRendererClone(enable);
  2630
+        }
  2631
+    }
  2632
+    else
  2633
+    {
  2634
+        if ((mVideoMode != VID_MODE_NORMAL) && (mVideoRenderer != NULL)) {
  2635
+            mVideoMode = VID_MODE_NORMAL;
  2636
+            mVideoRenderer->requestRendererClone(enable);
  2637
+        }
  2638
+    }
  2639
+    LOGD("CloneMode[%d]", mVideoMode);
  2640
+    return OK;
  2641
+}
  2642
+
  2643
+#endif
1916 2644
 
1917 2645
 }  // namespace android
1918 2646
 
Txt media/libstagefright/CameraSource.cpp
... ...
@@ -30,6 +30,11 @@
30 30
 #include <utils/String8.h>
31 31
 #include <cutils/properties.h>
32 32
 
  33
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  34
+#include <TICameraParameters.h>
  35
+#include "OMX_TI_Video.h"
  36
+#endif
  37
+
33 38
 namespace android {
34 39
 
35 40
 struct CameraSourceListener : public CameraListener {
... ...
@@ -37,9 +42,14 @@ struct CameraSourceListener : public CameraListener {
37 42
 
38 43
     virtual void notify(int32_t msgType, int32_t ext1, int32_t ext2);
39 44
     virtual void postData(int32_t msgType, const sp<IMemory> &dataPtr);
40  
-
  45
+#ifdef OMAP_ENHANCEMENT
  46
+    virtual void postDataTimestamp(
  47
+            nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr,
  48
+            uint32_t offset=0, uint32_t stride=0);
  49
+#else
41 50
     virtual void postDataTimestamp(
42 51
             nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
  52
+#endif
43 53
 
44 54
 protected:
45 55
     virtual ~CameraSourceListener();
... ...
@@ -67,12 +77,23 @@ void CameraSourceListener::postData(int32_t msgType, const sp<IMemory> &dataPtr)
67 77
          msgType, dataPtr->pointer(), dataPtr->size());
68 78
 }
69 79
 
  80
+#ifdef OMAP_ENHANCEMENT
70 81
 void CameraSourceListener::postDataTimestamp(
71  
-        nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr) {
  82
+        nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr,
  83
+        uint32_t offset, uint32_t stride)
  84
+#else
  85
+void CameraSourceListener::postDataTimestamp(
  86
+        nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr)
  87
+#endif
  88
+{
72 89
 
73 90
     sp<CameraSource> source = mSource.promote();
74 91
     if (source.get() != NULL) {
  92
+#ifdef OMAP_ENHANCEMENT
  93
+        source->dataCallbackTimestamp(timestamp/1000, msgType, dataPtr, offset, stride);
  94
+#else
75 95
         source->dataCallbackTimestamp(timestamp/1000, msgType, dataPtr);
  96
+#endif
76 97
     }
77 98
 }
78 99
 
... ...
@@ -82,11 +103,19 @@ static int32_t getColorFormat(const char* colorFormat) {
82 103
     }
83 104
 
84 105
     if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV420SP)) {
  106
+#if defined(TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  107
+        return OMX_COLOR_FormatYUV420PackedSemiPlanar;
  108
+#else
85 109
         return OMX_COLOR_FormatYUV420SemiPlanar;
  110
+#endif
86 111
     }
87 112
 
88 113
     if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_YUV422I)) {
  114
+#if defined(TARGET_OMAP3) && defined(OMAP_ENHANCEMENT)
  115
+        return OMX_COLOR_FormatCbYCrY;
  116
+#else
89 117
         return OMX_COLOR_FormatYCbYCr;
  118
+#endif
90 119
     }
91 120
 
92 121
     if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_RGB565)) {
... ...
@@ -99,6 +128,27 @@ static int32_t getColorFormat(const char* colorFormat) {
99 128
     CHECK_EQ(0, "Unknown color format");
100 129
 }
101 130
 
  131
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  132
+static int32_t getSEIEncodingType(const char* seiEncodingType)
  133
+{
  134
+    if (!strcmp(seiEncodingType, TICameraParameters::SEI_ENCODING_2004)) {
  135
+       return OMX_TI_Video_AVC_2004_StereoInfoType;
  136
+    }
  137
+
  138
+    if (!strcmp(seiEncodingType, TICameraParameters::SEI_ENCODING_2010)) {
  139
+        return OMX_TI_Video_AVC_2010_StereoFramePackingType;
  140
+    }
  141
+
  142
+    if (!strcmp(seiEncodingType, TICameraParameters::SEI_ENCODING_NONE)) {
  143
+        return OMX_TI_Video_Progressive;
  144
+    }
  145
+
  146
+    LOGE("Unsupported SEI encoding type (%s), reverting back to progressive", seiEncodingType);
  147
+
  148
+    return OMX_TI_Video_Progressive;
  149
+}
  150
+#endif
  151
+
102 152
 // static
103 153
 CameraSource *CameraSource::Create() {
104 154
     sp<Camera> camera = Camera::connect(0);
... ...
@@ -174,6 +224,54 @@ CameraSource::CameraSource(const sp<Camera> &camera)
174 224
     mMeta->setInt32(kKeyStride, stride);
175 225
     mMeta->setInt32(kKeySliceHeight, sliceHeight);
176 226
 
  227
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  228
+    int32_t paddedFrameWidth, paddedFrameHeight;
  229
+    if (mCamera != 0) {
  230
+        // Since we may not honor the preview size that app has requested
  231
+        // It is a good idea to get the actual preview size and use it for video recording.
  232
+        paddedFrameWidth = atoi(params.get("padded-width"));
  233
+        paddedFrameHeight = atoi(params.get("padded-height"));
  234
+        if (paddedFrameWidth < 0 || paddedFrameHeight < 0) {
  235
+            LOGE("Failed to get camera(%p) preview size", mCamera.get());
  236
+        }
  237
+        LOGV("CameraSource() : padded WxH=%dx%d", paddedFrameWidth, paddedFrameHeight);
  238
+    }
  239
+    else
  240
+    {
  241
+        LOGE("mCamera is NULL");
  242
+        paddedFrameWidth = width;
  243
+        paddedFrameHeight = height;
  244
+    }
  245
+
  246
+    mMeta->setInt32(kKeyPaddedWidth, paddedFrameWidth);
  247
+    mMeta->setInt32(kKeyPaddedHeight, paddedFrameHeight);
  248
+
  249
+    int32_t  mS3DCamera = false;
  250
+    if (mCamera != 0) {
  251
+
  252
+        if(params.get("s3d-supported")!= NULL && CameraParameters::TRUE != NULL)
  253
+            mS3DCamera = strcmp(params.get("s3d-supported"), CameraParameters::TRUE) == 0;
  254
+
  255
+        if(mS3DCamera)
  256
+        {
  257
+            const char *seiEncodingTypeStr = params.get(TICameraParameters::KEY_SEI_ENCODING_TYPE);
  258
+            CHECK(seiEncodingTypeStr != NULL);
  259
+            int32_t seiEncodingType = getSEIEncodingType(seiEncodingTypeStr);
  260
+            mMeta->setInt32(kKeySEIEncodingType, seiEncodingType);
  261
+
  262
+            const char *frameLayoutStr = params.get(TICameraParameters::KEY_S3D_FRAME_LAYOUT);
  263
+            CHECK(frameLayoutStr != NULL);
  264
+            mMeta->setCString(kKeyFrameLayout, frameLayoutStr);
  265
+        }
  266
+
  267
+    }
  268
+    else
  269
+    {
  270
+        LOGE("mCamera is NULL");
  271
+        mS3DCamera = false;
  272
+    }
  273
+    mMeta->setInt32(kKeyS3dSupported, mS3DCamera);
  274
+#endif
177 275
 }
178 276
 
179 277
 CameraSource::~CameraSource() {
... ...
@@ -288,6 +386,9 @@ status_t CameraSource::read(
288 386
     sp<IMemory> frame;
289 387
     int64_t frameTime;
290 388
 
  389
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  390
+    uint32_t frameOffset;
  391
+#endif
291 392
     {
292 393
         Mutex::Autolock autoLock(mLock);
293 394
         while (mStarted) {
... ...
@@ -302,6 +403,10 @@ status_t CameraSource::read(
302 403
             frame = *mFramesReceived.begin();
303 404
             mFramesReceived.erase(mFramesReceived.begin());
304 405
 
  406
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  407
+            frameOffset = *mFrameOffset.begin();
  408
+            mFrameOffset.erase(mFrameOffset.begin());
  409
+#endif
305 410
             frameTime = *mFrameTimes.begin();
306 411
             mFrameTimes.erase(mFrameTimes.begin());
307 412
             int64_t skipTimeUs;
... ...
@@ -326,6 +431,9 @@ status_t CameraSource::read(
326 431
                 (*buffer)->add_ref();
327 432
                 (*buffer)->meta_data()->setInt64(kKeyTime, frameTime);
328 433
 
  434
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  435
+                (*buffer)->meta_data()->setInt32(kKeyOffset, frameOffset);
  436
+#endif
329 437
                 return OK;
330 438
             }
331 439
         }
... ...
@@ -333,8 +441,15 @@ status_t CameraSource::read(
333 441
     return OK;
334 442
 }
335 443
 
  444
+#ifdef OMAP_ENHANCEMENT
336 445
 void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
337  
-        int32_t msgType, const sp<IMemory> &data) {
  446
+        int32_t msgType, const sp<IMemory> &data,
  447
+        uint32_t offset, uint32_t stride)
  448
+#else
  449
+void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
  450
+        int32_t msgType, const sp<IMemory> &data)
  451
+#endif
  452
+{
338 453
     LOGV("dataCallbackTimestamp: timestamp %lld us", timestampUs);
339 454
     Mutex::Autolock autoLock(mLock);
340 455
     if (!mStarted) {
... ...
@@ -373,6 +488,11 @@ void CameraSource::dataCallbackTimestamp(int64_t timestampUs,
373 488
     mFrameTimes.push_back(timeUs);
374 489
     LOGV("initial delay: %lld, current time stamp: %lld",
375 490
         mStartTimeUs, timeUs);
  491
+
  492
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  493
+    mFrameOffset.push_back(offset);
  494
+#endif
  495
+
376 496
     mFrameAvailableCondition.signal();
377 497
 }
378 498
 
Txt media/libstagefright/DataSource.cpp
... ...
@@ -31,6 +31,10 @@
31 31
 #include <media/stagefright/MediaErrors.h>
32 32
 #include <utils/String8.h>
33 33
 
  34
+#if defined(OMAP_ENHANCEMENT)
  35
+#include "include/ASFExtractor.h"
  36
+#endif
  37
+
34 38
 namespace android {
35 39
 
36 40
 bool DataSource::getUInt16(off_t offset, uint16_t *x) {
... ...
@@ -104,6 +108,11 @@ void DataSource::RegisterDefaultSniffers() {
104 108
     RegisterSniffer(SniffAMR);
105 109
     RegisterSniffer(SniffMPEG2TS);
106 110
     RegisterSniffer(SniffMP3);
  111
+#ifdef OMAP_ENHANCEMENT
  112
+    if(isASFParserAvailable()){
  113
+        RegisterSniffer(SniffASF);
  114
+    }
  115
+#endif
107 116
 }
108 117
 
109 118
 // static
Txt media/libstagefright/MPEG4Extractor.cpp
... ...
@@ -38,8 +38,44 @@
38 38
 #include <media/stagefright/Utils.h>
39 39
 #include <utils/String8.h>
40 40
 
  41
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  42
+#include "include/TISEIMessagesParser.h"
  43
+#endif
  44
+
41 45
 namespace android {
42 46
 
  47
+#ifdef OMAP_ENHANCEMENT
  48
+#define POS_ESDS_CANT_BE_FOUND(chunk_size) (chunk_size - 3)
  49
+/*Array containing the pointers to known types. This should be read only*/
  50
+    static const struct Mpeg4FileType{
  51
+        const char *const type;
  52
+        const uint8_t size;
  53
+    } knownFileTypes[] = {
  54
+    {"ftyp3gp", 7},
  55
+    {"ftypmp42", 8},
  56
+    {"ftyp3gr6", 8},
  57
+    {"ftyp3gs6", 8},
  58
+    {"ftyp3ge6", 8},
  59
+    {"ftyp3gg6", 8},
  60
+    {"ftypiso", 7},
  61
+    {"ftypM4V ", 8},
  62
+    {"ftypM4A ", 8},
  63
+    {"ftypf4v ", 8},
  64
+    {"ftypkddi", 8},
  65
+    {"ftypM4VP", 8},
  66
+    {"ftypqt", 6},
  67
+    {"ftypmmp4", 8},
  68
+    {"ftypmp41", 8},
  69
+    {"ftypwmf",  7},
  70
+    {"ftypMSNV", 8},
  71
+    {"ftyp3g2", 7},
  72
+    {"ftypskm2",8},
  73
+    {"ftypavc1",8}
  74
+    };
  75
+/*Indicates the number of known types and it should be linked to variable knownFileTypes*/
  76
+#define NUMBER_OF_KNOWN_FILE_TYPES (sizeof(knownFileTypes)/sizeof(struct Mpeg4FileType))
  77
+#endif
  78
+
43 79
 class MPEG4Source : public MediaSource {
44 80
 public:
45 81
     // Caller retains ownership of both "dataSource" and "sampleTable".
... ...
@@ -48,6 +84,9 @@ public:
48 84
                 int32_t timeScale,
49 85
                 const sp<SampleTable> &sampleTable);
50 86
 
  87
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  88
+    virtual void parseSEIMessages(S3D_params &mS3Dparams);
  89
+#endif
51 90
     virtual status_t start(MetaData *params = NULL);
52 91
     virtual status_t stop();
53 92
 
... ...
@@ -70,7 +109,9 @@ private:
70 109
 
71 110
     bool mIsAVC;
72 111
     size_t mNALLengthSize;
73  
-
  112
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  113
+    size_t SEINALLength;
  114
+#endif
74 115
     bool mStarted;
75 116
 
76 117
     MediaBufferGroup *mGroup;
... ...
@@ -249,6 +290,10 @@ static const char *FourCC2MIME(uint32_t fourcc) {
249 290
         case FOURCC('s', '2', '6', '3'):
250 291
             return MEDIA_MIMETYPE_VIDEO_H263;
251 292
 
  293
+#ifdef OMAP_ENHANCEMENT
  294
+        case FOURCC('H', '2', '6', '3'):
  295
+            return MEDIA_MIMETYPE_VIDEO_H263;
  296
+#endif
252 297
         case FOURCC('a', 'v', 'c', '1'):
253 298
             return MEDIA_MIMETYPE_VIDEO_AVC;
254 299
 
... ...
@@ -323,7 +368,31 @@ sp<MetaData> MPEG4Extractor::getTrackMetaData(
323 368
     if (track == NULL) {
324 369
         return NULL;
325 370
     }
326  
-
  371
+#ifdef OMAP_ENHANCEMENT
  372
+    if (flags & kIncludeExtensiveMetaData){
  373
+        track->includes_expensive_metadata = true;
  374
+        const char *mime;
  375
+        CHECK(track->meta->findCString(kKeyMIMEType, &mime));
  376
+        if (!strncasecmp("video/", mime, 6)) {
  377
+            uint32_t sampleIndex=0;
  378
+            uint32_t sampleTime;
  379
+            if (flags & kSelectFirstSample || track->sampleTable->findThumbnailSample(&sampleIndex) != OK){
  380
+                /*It will be forced the frame zero which is supposed to
  381
+                 *be an I frame every time.
  382
+                 * */
  383
+                LOGD("Forced first sample\n");
  384
+                sampleIndex=0;
  385
+            }
  386
+            if (track->sampleTable->getMetaDataForSample(
  387
+                        sampleIndex, NULL /* offset */, NULL /* size */,
  388
+                        &sampleTime) == OK) {
  389
+                track->meta->setInt64(
  390
+                        kKeyThumbnailTime,
  391
+                        ((int64_t)sampleTime * 1000000) / track->timescale);
  392
+            }
  393
+        }
  394
+    }
  395
+#else
327 396
     if ((flags & kIncludeExtensiveMetaData)
328 397
             && !track->includes_expensive_metadata) {
329 398
         track->includes_expensive_metadata = true;
... ...
@@ -343,7 +412,7 @@ sp<MetaData> MPEG4Extractor::getTrackMetaData(
343 412
             }
344 413
         }
345 414
     }
346  
-
  415
+#endif
347 416
     return track->meta;
348 417
 }
349 418
 
... ...
@@ -360,6 +429,36 @@ status_t MPEG4Extractor::readMetaData() {
360 429
     if (mHaveMetadata) {
361 430
         if (mHasVideo) {
362 431
             mFileMetaData->setCString(kKeyMIMEType, "video/mp4");
  432
+#ifdef OMAP_ENHANCEMENT
  433
+            Track *tempTrack = mFirstTrack;
  434
+            int count = 0;
  435
+            const char *mime;
  436
+            while (tempTrack) {
  437
+        CHECK(tempTrack->meta->findCString(kKeyMIMEType, &mime));
  438
+
  439
+        if (!strncasecmp("video/", mime, 6)) {
  440
+
  441
+          size_t totalframes;
  442
+          int64_t duration;
  443
+          int32_t dur32,fps;
  444
+
  445
+          fps = 0;
  446
+                                        totalframes = tempTrack->sampleTable->countSamples();
  447
+          tempTrack->meta->findInt64(kKeyDuration, &duration);
  448
+
  449
+          dur32 =  (int32_t) (duration / 1000000);
  450
+                                        if(dur32 <=0){
  451
+                                            //dur32 will be zero for clips < 1 second.
  452
+                                            dur32 = 1;
  453
+                                        }
  454
+                                        fps = totalframes/dur32;
  455
+                                        LOGV("totalframes %d duration %lld dur32 %d fps %d",totalframes,duration,dur32,fps);
  456
+          tempTrack->meta->setInt32(kKeyVideoFPS,fps);
  457
+        }
  458
+        tempTrack= tempTrack->next;
  459
+            }
  460
+#endif
  461
+
363 462
         } else {
364 463
             mFileMetaData->setCString(kKeyMIMEType, "audio/mp4");
365 464
         }
... ...
@@ -415,6 +514,12 @@ static void convertTimeToDate(int64_t time_1904, String8 *s) {
415 514
 
416 515
 status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
417 516
     uint32_t hdr[2];
  517
+#ifdef  OMAP_ENHANCEMENT
  518
+    // A copy of the unmodified offset; needed to skip unrecognized
  519
+    // atoms (unrecognized by this logic means that its name isn't
  520
+    // recognized in the switch below)
  521
+    off_t originalOffset=*offset;
  522
+#endif
418 523
     if (mDataSource->readAt(*offset, hdr, 8) < 8) {
419 524
         return ERROR_IO;
420 525
     }
... ...
@@ -433,11 +538,17 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
433 538
             // The smallest valid chunk is 16 bytes long in this case.
434 539
             return ERROR_MALFORMED;
435 540
         }
436  
-    } else if (chunk_size < 8) {
  541
+#ifdef OMAP_ENHANCEMENT
  542
+    } else if ((chunk_size < 8) && (chunk_size != 0)){
437 543
         // The smallest valid chunk is 8 bytes long.
438 544
         return ERROR_MALFORMED;
439 545
     }
440  
-
  546
+#else
  547
+    } else if (chunk_size < 8){
  548
+        // The smallest valid chunk is 8 bytes long.
  549
+        return ERROR_MALFORMED;
  550
+    }
  551
+#endif
441 552
     char chunk[5];
442 553
     MakeFourCCString(chunk_type, chunk);
443 554
 
... ...
@@ -480,7 +591,28 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
480 591
 
481 592
         return OK;
482 593
     }
  594
+#ifdef OMAP_ENHANCEMENT
  595
+    {
  596
+        union {
  597
+            uint32_t chunk;
  598
+            uint8_t t[4];
  599
+        }chnk;
  600
+        chnk.chunk=chunk_type;
  601
+        LOGV("Chunk: %c%c%c%c\n", chnk.t[3],chnk.t[2],chnk.t[1],chnk.t[0]);
  602
+    }
483 603
 
  604
+    // If the size of the atom is zero, then this is an empty atom that
  605
+    //  needs to be skipped; the way to skip it is by making its size 4,
  606
+    //  so the next time the instruction *offset += chunk_size happen
  607
+    //  the atom be skipped and it doesn't cause the parser enter in
  608
+    //  aninfinite loop.
  609
+    //  (*offset would be pointing to the same place again and again if
  610
+    //  chunk_size is zero)
  611
+
  612
+    if (!chunk_size){
  613
+        chunk_size=4;
  614
+    }
  615
+#endif
484 616
     switch(chunk_type) {
485 617
         case FOURCC('m', 'o', 'o', 'v'):
486 618
         case FOURCC('t', 'r', 'a', 'k'):
... ...
@@ -693,6 +825,153 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
693 825
         case FOURCC('m', 'p', '4', 'a'):
694 826
         case FOURCC('s', 'a', 'm', 'r'):
695 827
         case FOURCC('s', 'a', 'w', 'b'):
  828
+#ifdef OMAP_ENHANCEMENT
  829
+        {
  830
+            // This pointer will hold the address of a buffer with the
  831
+            // data content inside the mp4a, samr or sawb atoms.
  832
+
  833
+            uint8_t *buffer;
  834
+
  835
+            // Allocate buffer content
  836
+
  837
+            if (!(buffer = (uint8_t *)malloc(chunk_size))){
  838
+                LOGD("Error allocating memory\n");
  839
+                *offset += chunk_size;
  840
+                return ERROR_OUT_OF_MEM;
  841
+            }
  842
+            // Fill out the buffer with the data
  843
+
  844
+            if (mDataSource->readAt(
  845
+                        data_offset, buffer, chunk_size) < (ssize_t) chunk_size) {
  846
+                free(buffer);
  847
+                return ERROR_IO;
  848
+            }
  849
+            uint16_t data_ref_index = 0;
  850
+            uint16_t num_channels = 0;
  851
+            uint16_t sample_size = 0;
  852
+            uint32_t sample_rate = 0;
  853
+            if (chunk_size >= 25){
  854
+                data_ref_index = U16_AT(&buffer[6]);
  855
+                num_channels = U16_AT(&buffer[16]);
  856
+
  857
+                sample_size = U16_AT(&buffer[18]);
  858
+                sample_rate = U32_AT(&buffer[24]) >> 16;
  859
+            }
  860
+
  861
+            if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB,
  862
+                            FourCC2MIME(chunk_type))) {
  863
+                // AMR NB audio is always mono, 8kHz
  864
+                num_channels = 1;
  865
+                sample_rate = 8000;
  866
+            } else if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB,
  867
+                               FourCC2MIME(chunk_type))) {
  868
+                // AMR WB audio is always mono, 16kHz
  869
+                num_channels = 1;
  870
+                sample_rate = 16000;
  871
+            }
  872
+
  873
+            LOGV("*** coding='%s' %d channels, size %d, rate %d\n",
  874
+                   chunk, num_channels, sample_size, sample_rate);
  875
+
  876
+            mLastTrack->meta->setCString(kKeyMIMEType, FourCC2MIME(chunk_type));
  877
+            mLastTrack->meta->setInt32(kKeyChannelCount, num_channels);
  878
+            mLastTrack->meta->setInt32(kKeySampleRate, sample_rate);
  879
+
  880
+            // The following section of code is like a parser that
  881
+            // replaces the complete processing of the atoms mp4a, samr,
  882
+            // and sawb.
  883
+            // For each case, ideally there should be different parsers,
  884
+            // but all should yield to the position of the esds atom.
  885
+            // A search for a string is implemented (something like
  886
+            // strstr but for chains that can have '\0' chars in the
  887
+            // stream)
  888
+            // In fact the code below is a modification of strstr
  889
+
  890
+
  891
+            //s will store the position of the esds atom
  892
+            uint8_t * s = (uint8_t *)buffer;
  893
+            {
  894
+                char c, sc;
  895
+                // This is a modification of strstr; since
  896
+                // '\0' is allowed, the stop logic will work
  897
+                // by knowing the size of the array (instead of looking
  898
+                // for '/0')
  899
+
  900
+                unsigned int count = 0;
  901
+                // This is the tag that needs to be found.
  902
+
  903
+                const char * find = "esds";
  904
+                c = *find++;
  905
+                do {
  906
+                    do {
  907
+                        sc = *s++;
  908
+                        count++;
  909
+                    } while (sc != c && count < POS_ESDS_CANT_BE_FOUND(chunk_size));
  910
+                } while ((memcmp(s, find, 3)) && count < POS_ESDS_CANT_BE_FOUND(chunk_size));
  911
+                s--;
  912
+            }
  913
+
  914
+            // The stop offset indicates the place where the current
  915
+            // atom should end.
  916
+
  917
+            off_t stop_offset = *offset + chunk_size;
  918
+            // Check if the parsing succeeded or not. If it didn't,
  919
+            // there is still chance to properly play the file so no
  920
+            // error will be reported, yet.
  921
+
  922
+            if (s==buffer + POS_ESDS_CANT_BE_FOUND(chunk_size)
  923
+                || !(s-buffer)){
  924
+                LOGD("esds not found continue parsing next atoms\n");
  925
+                *offset = stop_offset;
  926
+                free(buffer);
  927
+                break;
  928
+            }
  929
+
  930
+            // esds atom was found. Set the offset to the place where
  931
+            // the atom was found, and rewind 4 bytes in order to seek
  932
+            // from the place the atom's size is found.
  933
+
  934
+            *offset = data_offset + (s - buffer) - 4;
  935
+
  936
+            // Information found or not found, there is no need for
  937
+            // the buffer anymore.
  938
+
  939
+            free(buffer);
  940
+
  941
+            // Parse esds atom
  942
+
  943
+            while (*offset < stop_offset) {
  944
+                status_t err = parseChunk(offset, depth + 1);
  945
+                if (err != OK) {
  946
+                    // If the esds atom couldn't be parsed, then try to
  947
+                    // continue parsing the other atoms and use the
  948
+                    // default values.
  949
+
  950
+                    LOGD("Malformed\n");
  951
+                    LOGD("Error while parsing audio metadata, should use default settings\n");
  952
+                }
  953
+            }
  954
+
  955
+            // This error will not be forgiven since this indicates
  956
+            // the esds parser jumped above the size of the atom and
  957
+            // attempted to read more information than what was
  958
+            // contained in esds. (Case when the parser reads all the
  959
+            // info and expects to find more, but it can't)
  960
+            // However, if the offset is smaller, then the esds parser
  961
+            // wasn't able to complete its parsing, this could be due
  962
+            // to the fact it couldn't recognize a pattern in the esds
  963
+            // atom; This indicates that some information could have
  964
+            // been extracted from the esds, but not all and this parser
  965
+            // will attempt to continue launching the application with
  966
+            // the collected information (which may not be complete).
  967
+
  968
+            if (*offset > stop_offset) {
  969
+                return ERROR_MALFORMED;
  970
+            }
  971
+
  972
+            break;
  973
+        }
  974
+#else
696 975
         {
697 976
             uint8_t buffer[8 + 20];
698 977
             if (chunk_data_size < (ssize_t)sizeof(buffer)) {
... ...
@@ -746,9 +1025,12 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
746 1025
             }
747 1026
             break;
748 1027
         }
749  
-
  1028
+#endif
750 1029
         case FOURCC('m', 'p', '4', 'v'):
751 1030
         case FOURCC('s', '2', '6', '3'):
  1031
+#ifdef OMAP_ENHANCEMENT
  1032
+        case FOURCC('H', '2', '6', '3'):
  1033
+#endif
752 1034
         case FOURCC('a', 'v', 'c', '1'):
753 1035
         {
754 1036
             mHasVideo = true;
... ...
@@ -847,6 +1129,21 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
847 1129
             break;
848 1130
         }
849 1131
 
  1132
+#ifdef OMAP_ENHANCEMENT
  1133
+        case FOURCC('c', 't', 't', 's'):
  1134
+        {
  1135
+            status_t err =
  1136
+                mLastTrack->sampleTable->setTimeToSampleParamsCtts(
  1137
+                        data_offset, chunk_data_size);
  1138
+
  1139
+            if (err != OK) {
  1140
+                return err;
  1141
+            }
  1142
+
  1143
+            *offset += chunk_size;
  1144
+            break;
  1145
+        }
  1146
+#endif
850 1147
         case FOURCC('s', 't', 't', 's'):
851 1148
         {
852 1149
             status_t err =
... ...
@@ -910,6 +1207,11 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
910 1207
                         &buffer[4], chunk_data_size - 4);
911 1208
 
912 1209
                 if (err != OK) {
  1210
+#ifdef OMAP_ENHANCEMENT
  1211
+                    LOGD("Error retrieving audio metadata, attempt to "
  1212
+                    "continue by skipping the atom\n");
  1213
+                    *offset += chunk_size;
  1214
+#endif
913 1215
                     return err;
914 1216
                 }
915 1217
             }
... ...
@@ -1020,9 +1322,29 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
1020 1322
             break;
1021 1323
         }
1022 1324
 
  1325
+#ifdef OMAP_ENHANCEMENT
  1326
+        case FOURCC('d', 'a', 'm', 'r'):
  1327
+        {
  1328
+             // validate chunk size of damr ATOM
  1329
+             if((chunk_data_size > 9)||(chunk_data_size < 0)){
  1330
+                 LOGV(" Chunk data size is INVALID ");
  1331
+                 return ERROR_MALFORMED;
  1332
+             }
  1333
+
  1334
+             *offset += chunk_size;
  1335
+             break;
  1336
+        }
  1337
+#endif
  1338
+
1023 1339
         default:
1024 1340
         {
  1341
+#ifdef OMAP_ENHANCEMENT
  1342
+            // Skip this unknown atom
  1343
+
  1344
+            *offset = originalOffset + chunk_size;
  1345
+#else
1025 1346
             *offset += chunk_size;
  1347
+#endif
1026 1348
             break;
1027 1349
         }
1028 1350
     }
... ...
@@ -1417,6 +1739,9 @@ MPEG4Source::MPEG4Source(
1417 1739
       mCurrentSampleIndex(0),
1418 1740
       mIsAVC(false),
1419 1741
       mNALLengthSize(0),
  1742
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1743
+      SEINALLength(0),
  1744
+#endif
1420 1745
       mStarted(false),
1421 1746
       mGroup(NULL),
1422 1747
       mBuffer(NULL),
... ...
@@ -1450,6 +1775,88 @@ MPEG4Source::~MPEG4Source() {
1450 1775
     }
1451 1776
 }
1452 1777
 
  1778
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1779
+void MPEG4Source::parseSEIMessages(S3D_params &mS3Dparams) {
  1780
+    status_t stats=0;
  1781
+
  1782
+    if (mIsAVC) {
  1783
+        int32_t max_size;
  1784
+        CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));
  1785
+
  1786
+        int nalType, nalRefIdc;
  1787
+        status_t res;
  1788
+        size_t srcOffset = 0, size;
  1789
+
  1790
+        MediaBuffer *out = NULL;
  1791
+        uint8_t *myData;
  1792
+
  1793
+        status_t err = this->start();
  1794
+        if (err != OK)
  1795
+            goto EXIT;
  1796
+
  1797
+        err = read(&out);
  1798
+        if (err != OK)
  1799
+            goto EXIT;
  1800
+
  1801
+        myData = (uint8_t *)out->data();
  1802
+        // Getting the size read
  1803
+        size = out->size();
  1804
+        while (srcOffset < (size-4)) {
  1805
+            if((myData[srcOffset] == 0) &&
  1806
+                (myData[srcOffset+1] == 0) &&
  1807
+                (myData[srcOffset+2] == 0) &&
  1808
+                (myData[srcOffset+3] == 1))
  1809
+            {
  1810
+                srcOffset +=mNALLengthSize;
  1811
+                res = AVCGetNALType(&myData[srcOffset], (size-(srcOffset +mNALLengthSize)),&nalType, &nalRefIdc);
  1812
+                if (res)
  1813
+                {
  1814
+                    LOGE("FAILED Cannot determine nal type");
  1815
+                    goto EXIT;
  1816
+                }
  1817
+
  1818
+                switch (nalType)
  1819
+                {
  1820
+                    case AVC_NALTYPE_SEI:
  1821
+                    {
  1822
+                        LOGV("Calling DecodeSEI() \n");
  1823
+                        res = sei_rbsp(&myData[srcOffset], SEINALLength, mS3Dparams);//(size-(srcOffset +mNALLengthSize))
  1824
+                        if(res)
  1825
+                        {
  1826
+                            LOGE("FAILED parsing SEI messages \n");
  1827
+                            goto EXIT;
  1828
+                        }
  1829
+                        break;
  1830
+                    }
  1831
+                    default:
  1832
+                    {
  1833
+                        LOGV("Default value for NALType %d \n", nalType);
  1834
+                        break;
  1835
+                    }
  1836
+                }
  1837
+            }
  1838
+            else
  1839
+            {
  1840
+                srcOffset++;
  1841
+                if (srcOffset + mNALLengthSize>= size)
  1842
+                {
  1843
+                    LOGV("No more NAL Unit \n");
  1844
+                    goto EXIT;
  1845
+                }
  1846
+            }
  1847
+        }
  1848
+
  1849
+        EXIT:
  1850
+        if(out != NULL)
  1851
+        {
  1852
+            out->release();
  1853
+            out = NULL;myData=NULL;
  1854
+        }
  1855
+       this->stop();
  1856
+    }
  1857
+}
  1858
+#endif
  1859
+
1453 1860
 status_t MPEG4Source::start(MetaData *params) {
1454 1861
     Mutex::Autolock autoLock(mLock);
1455 1862
 
... ...
@@ -1530,7 +1937,9 @@ status_t MPEG4Source::read(
1530 1937
 
1531 1938
     CHECK(mStarted);
1532 1939
 
  1940
+#if !defined(TARGET_OMAP4)
1533 1941
     *out = NULL;
  1942
+#endif
1534 1943
 
1535 1944
     int64_t targetSampleTimeUs = -1;
1536 1945
 
... ...
@@ -1618,7 +2027,11 @@ status_t MPEG4Source::read(
1618 2027
     uint32_t dts;
1619 2028
     bool isSyncSample;
1620 2029
     bool newBuffer = false;
  2030
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2031
+    if (mBuffer == NULL || (*out && !mWantsNALFragments)) {
  2032
+#else
1621 2033
     if (mBuffer == NULL) {
  2034
+#endif
1622 2035
         newBuffer = true;
1623 2036
 
1624 2037
         status_t err =
... ...
@@ -1629,7 +2042,15 @@ status_t MPEG4Source::read(
1629 2042
             return err;
1630 2043
         }
1631 2044
 
  2045
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2046
+        if (NULL == *out || mWantsNALFragments) {
  2047
+            err = mGroup->acquire_buffer(&mBuffer);
  2048
+        } else {
  2049
+            mBuffer = *out;
  2050
+        }
  2051
+#else
1632 2052
         err = mGroup->acquire_buffer(&mBuffer);
  2053
+#endif
1633 2054
 
1634 2055
         if (err != OK) {
1635 2056
             CHECK(mBuffer == NULL);
... ...
@@ -1650,6 +2071,12 @@ status_t MPEG4Source::read(
1650 2071
             }
1651 2072
 
1652 2073
             CHECK(mBuffer != NULL);
  2074
+#ifdef OMAP_ENHANCEMENT
  2075
+            if(mSampleTable->mTimeToSampleCtts) {
  2076
+                dts += mSampleTable->mTimeToSampleCtts[mCurrentSampleIndex];
  2077
+            }
  2078
+#endif
  2079
+
1653 2080
             mBuffer->set_range(0, size);
1654 2081
             mBuffer->meta_data()->clear();
1655 2082
             mBuffer->meta_data()->setInt64(
... ...
@@ -1712,7 +2139,53 @@ status_t MPEG4Source::read(
1712 2139
     } else {
1713 2140
         // Whole NAL units are returned but each fragment is prefixed by
1714 2141
         // the start code (0x00 00 00 01).
  2142
+#ifdef OMAP_ENHANCEMENT
  2143
+        uint8_t *dstData = (uint8_t *)mBuffer->data();
  2144
+        size_t srcOffset = 0;
  2145
+        size_t dstOffset = 0;
  2146
+
  2147
+        while (srcOffset < size) {
  2148
+            CHECK(srcOffset + mNALLengthSize <= size);
  2149
+            ssize_t num_bytes_read = mDataSource->readAt(offset+srcOffset, mSrcBuffer, mNALLengthSize);
  2150
+            if (num_bytes_read < (ssize_t)mNALLengthSize) {
  2151
+                mBuffer->release();
  2152
+                mBuffer = NULL;
  2153
+                return ERROR_IO;
  2154
+            }
  2155
+            size_t nalLength = parseNALSize(&mSrcBuffer[0]);
  2156
+            srcOffset += mNALLengthSize;
  2157
+            if (srcOffset + nalLength > size) {
  2158
+                mBuffer->release();
  2159
+                mBuffer = NULL;
  2160
+                return ERROR_MALFORMED;
  2161
+            }
1715 2162
 
  2163
+            if (nalLength == 0) {
  2164
+                continue;
  2165
+            }
  2166
+
  2167
+            CHECK(dstOffset + 4 <= mBuffer->size());
  2168
+
  2169
+            dstData[dstOffset++] = 0;
  2170
+            dstData[dstOffset++] = 0;
  2171
+            dstData[dstOffset++] = 0;
  2172
+            dstData[dstOffset++] = 1;
  2173
+            num_bytes_read = mDataSource->readAt(offset+srcOffset, &dstData[dstOffset], nalLength);
  2174
+            if (num_bytes_read < (ssize_t)nalLength) {
  2175
+                 mBuffer->release();
  2176
+                 mBuffer = NULL;
  2177
+                 return ERROR_IO;
  2178
+            }
  2179
+#if defined(TARGET_OMAP4)
  2180
+            // Getting NAL length for SEI messages Gilles
  2181
+            if(dstData[dstOffset] == AVC_NALTYPE_SEI)
  2182
+                SEINALLength = nalLength;
  2183
+#endif
  2184
+            srcOffset += nalLength;
  2185
+            dstOffset += nalLength;
  2186
+        }
  2187
+        CHECK_EQ(srcOffset, size);
  2188
+#else
1716 2189
         ssize_t num_bytes_read =
1717 2190
             mDataSource->readAt(offset, mSrcBuffer, size);
1718 2191
 
... ...
@@ -1754,10 +2227,16 @@ status_t MPEG4Source::read(
1754 2227
             dstOffset += nalLength;
1755 2228
         }
1756 2229
         CHECK_EQ(srcOffset, size);
  2230
+#endif
1757 2231
 
1758 2232
         CHECK(mBuffer != NULL);
1759 2233
         mBuffer->set_range(0, dstOffset);
1760 2234
         mBuffer->meta_data()->clear();
  2235
+#ifdef OMAP_ENHANCEMENT
  2236
+        if(mSampleTable->mTimeToSampleCtts)
  2237
+            dts = dts + mSampleTable->mTimeToSampleCtts[mCurrentSampleIndex];
  2238
+#endif
  2239
+
1761 2240
         mBuffer->meta_data()->setInt64(
1762 2241
                 kKeyTime, ((int64_t)dts * 1000000) / mTimescale);
1763 2242
 
... ...
@@ -1866,7 +2345,217 @@ static bool BetterSniffMPEG4(
1866 2345
 
1867 2346
     return true;
1868 2347
 }
  2348
+#ifdef OMAP_ENHANCEMENT
  2349
+bool positionFileAtAtom (const sp<DataSource> &source, uint32_t &offsetToNextAtom, const char *patern, off_t fileSize, uint32_t &atomSize) {
  2350
+    /*Fail safe counter*/
  2351
+    uint32_t failSafe = 0;
  2352
+    /*Stores the return value from comparations*/
  2353
+    int memCompRetVal;
  2354
+    /*Stores the analyzed atom's name and size*/
  2355
+    struct {
  2356
+        union {
  2357
+            uint32_t size;
  2358
+            uint8_t sizeArray[4];
  2359
+        } atomSize;
  2360
+        uint8_t  atomName[4];
  2361
+    } atomNameAndSize;
  2362
+
  2363
+    /*Check parameters*/
  2364
+
  2365
+    /*Init Atom Size to null*/
  2366
+    atomNameAndSize.atomSize.size = 0;
  2367
+
  2368
+    do {
  2369
+        /*increment the fail safe counter*/
  2370
+        failSafe++;
  2371
+
  2372
+        /*Jump to the next atom and read its type*/
  2373
+
  2374
+        /*Compute offset where the atom is stored*/
  2375
+        offsetToNextAtom += atomNameAndSize.atomSize.size;
  2376
+
  2377
+        /*Check the size is within the file size. Currently this is limited to a file of 2GB*/
  2378
+        if (fileSize > 0 && offsetToNextAtom >= (unsigned)fileSize) {
  2379
+            /*Bad offset*/
  2380
+            return false;
  2381
+        }
  2382
+
  2383
+
  2384
+        /*Read the cached info*/
  2385
+        if (source->readAt(offsetToNextAtom, &atomNameAndSize, sizeof(atomNameAndSize)) < (signed)sizeof(atomNameAndSize)) {
  2386
+            /*Couldnt read the atom's type and size*/
  2387
+            LOGD("Couldnt find next atom");
  2388
+            return false;
  2389
+        }
  2390
+
  2391
+        /*The size is in big endian, so it is necesary to convert the value so it can be used*/
  2392
+        /*Swap the framing bytes*/
  2393
+        atomNameAndSize.atomSize.sizeArray[0] ^= atomNameAndSize.atomSize.sizeArray[3];
  2394
+        atomNameAndSize.atomSize.sizeArray[3] ^= atomNameAndSize.atomSize.sizeArray[0];
  2395
+        atomNameAndSize.atomSize.sizeArray[0] ^= atomNameAndSize.atomSize.sizeArray[3];
  2396
+        /*Swap the middle bytes*/
  2397
+        atomNameAndSize.atomSize.sizeArray[1] ^= atomNameAndSize.atomSize.sizeArray[2];
  2398
+        atomNameAndSize.atomSize.sizeArray[2] ^= atomNameAndSize.atomSize.sizeArray[1];
  2399
+        atomNameAndSize.atomSize.sizeArray[1] ^= atomNameAndSize.atomSize.sizeArray[2];
  2400
+
  2401
+        LOGD("Atom found: %c%c%c%c with size = %x\n", atomNameAndSize.atomName[0], atomNameAndSize.atomName[1], atomNameAndSize.atomName[2], atomNameAndSize.atomName[3], atomNameAndSize.atomSize.size);
  2402
+    } while ((memCompRetVal = memcmp(atomNameAndSize.atomName, patern, 4))  && atomNameAndSize.atomSize.size && atomNameAndSize.atomSize.size >= 8 && failSafe < 10 && (offsetToNextAtom+atomNameAndSize.atomSize.size) < (unsigned)fileSize);
  2403
+
  2404
+
  2405
+    /*Check if the atom was found or that the iterations ended due to an error*/
  2406
+    if ((memCompRetVal) && ((offsetToNextAtom+atomNameAndSize.atomSize.size) < (unsigned)fileSize)) {
  2407
+        /*Didn't find it return with no success*/
  2408
+        return false;
  2409
+    }
  2410
+
  2411
+    /*If this point is reach the atom was found*/
  2412
+    atomSize = atomNameAndSize.atomSize.size;
  2413
+    return true;
  2414
+}
  2415
+
  2416
+bool SniffMPEG4(const sp<DataSource> &source, String8 *mimeType, float *confidence, sp<AMessage> *) {
  2417
+
  2418
+    /*Stores the ftyp type*/
  2419
+    uint8_t header[8];
  2420
+    /*Stores the return value from comparations*/
  2421
+    int memCompRetVal;
  2422
+
  2423
+    /*Read the header*/
  2424
+    if (source->readAt(4, header, sizeof(header)) < (signed)sizeof(header)) {
  2425
+        /*Couldnt read ftyp's atom's type*/
  2426
+        LOGD("Couldnt read ftyps atom type");
  2427
+        return false;
  2428
+    }
  2429
+
  2430
+    /*Look for known type headers*/
  2431
+    memCompRetVal = true;
  2432
+
  2433
+    for (int i = 0; i < NUMBER_OF_KNOWN_FILE_TYPES; i++) {
  2434
+        if (!(memCompRetVal = memcmp(header, knownFileTypes[i].type, knownFileTypes[i].size))) {
  2435
+            /*header has been found*/
  2436
+            break;
  2437
+        }
  2438
+    }
  2439
+
  2440
+#ifdef OMAP_ENHANCEMENT
  2441
+    bool mdat_result = memcmp(header, "mdat", 4);
  2442
+
  2443
+    /*Exit if the pattern wasn't found*/
  2444
+    if (memCompRetVal && mdat_result ) {
  2445
+#else
  2446
+    if (memCompRetVal) {
  2447
+#endif
  2448
+        /*Couldn't find the pattern*/
  2449
+#ifdef OMAP_ENHANCEMENT
  2450
+        LOGE("both mdat,ftyp not found");
  2451
+#endif
  2452
+        return false;
  2453
+    }
  2454
+
  2455
+    /*header has been found set the confidence to .1*/
  2456
+    *confidence=0.1f;
  2457
+    *mimeType = MEDIA_MIMETYPE_CONTAINER_MPEG4;
  2458
+
  2459
+    /*See if the confidence can be increased
  2460
+     *since the header was found the result will be true in any case
  2461
+     *the only thing that would change is the confidence.*/
  2462
+
  2463
+    /*The file type matched one in the known list, look for the track indicating a video handler*/
  2464
+    {
  2465
+        /*Stores the file size this is a signed value compared to the unsigned value used to store the atom's sizes*/
  2466
+        off_t fileSize;
  2467
+        /*Stores the computed offset to the new atom*/
  2468
+        uint32_t offsetToSeek;
  2469
+        /*Stores the atom's size*/
  2470
+        uint32_t atomSize;
  2471
+        /*fail safe counter*/
  2472
+        uint8_t failCounter;
  2473
+        /*Handler type*/
  2474
+        uint8_t handler[4];
  2475
+        /*Location of the first track atom*/
  2476
+        uint32_t trakOffset;
  2477
+        /*Stores the atom's track size*/
  2478
+        uint32_t trakSize;
  2479
+
  2480
+        /*Initialize the file size variable*/
  2481
+        if (source->getSize(&fileSize)) {
  2482
+            /*couldn't get the file size nor increase confidence*/
  2483
+            return true;
  2484
+        }
  2485
+
  2486
+        /*Look for the moov atom from the begining of the file*/
  2487
+        offsetToSeek = 0;
  2488
+
  2489
+        if (!positionFileAtAtom(source, offsetToSeek, "moov", fileSize, atomSize)) {
  2490
+            /*Couldn't find moov atom, return true as header was found*/
  2491
+            return true;
  2492
+        }
  2493
+
  2494
+        /*Once the moov atom has been found inspect each of the trak atoms looking for the vide handler*/
  2495
+        failCounter = 0;
  2496
+        /*Skip the header of the moov atom*/
  2497
+        offsetToSeek += 8;
  2498
+
  2499
+        do {
  2500
+            failCounter++;
  2501
+
  2502
+            if (!positionFileAtAtom(source, offsetToSeek, "trak", fileSize, atomSize)) {
  2503
+                /*Couldn't find trak atom, return true as the header was found*/
  2504
+                return true;
  2505
+            }
  2506
+
  2507
+            /*Store the position of the track atom and its size for future references*/
  2508
+            trakOffset = offsetToSeek;
  2509
+            trakSize = atomSize;
  2510
+
  2511
+            /*Look for the mdia atom inside the trak atom*/
  2512
+            /*Skip the header of the atom*/
  2513
+            offsetToSeek += 8;
  2514
+
  2515
+            if (!positionFileAtAtom(source, offsetToSeek, "mdia", fileSize, atomSize)) {
  2516
+                /*Couldn't find mdia atom, return true as header was found*/
  2517
+                return true;
  2518
+            }
  2519
+
  2520
+            /*Look for the hdlr atom inside the mdia atom*/
  2521
+            /*Skip the header of the atom*/
  2522
+            offsetToSeek += 8;
  2523
+
  2524
+            if (!positionFileAtAtom(source, offsetToSeek, "hdlr", fileSize, atomSize)) {
  2525
+                /*Couldn't find hdlr atom, return true as header was found*/
  2526
+                return true;
  2527
+            }
  2528
+
  2529
+            /*Read the handler*/
  2530
+            /*Adjust the offset to skip the null information*/
  2531
+            offsetToSeek += 0x10;
  2532
+
  2533
+            if (source->readAt(offsetToSeek, &handler, sizeof(handler)) < sizeof(handler)) {
  2534
+                /*Couldnt read the atom's type and size*/
  2535
+                LOGD("Couldnt read the handler");
  2536
+                return true;
  2537
+            }
  2538
+
  2539
+            /*Adjust the offset to look for the next trak atom*/
  2540
+            offsetToSeek = trakOffset + trakSize;
  2541
+        } while (memCompRetVal = memcmp(handler, "vide", 4) && failCounter < 10 && (offsetToSeek < fileSize));
  2542
+
  2543
+       /*For some clips which have only audio track, the above loop goes till the end of the file,
  2544
+       * without finding video handler, this is not an issue. And there is no string match for audio track,
  2545
+       * becuase such clips are found to be having NULL string for handler component name.
  2546
+       * Here the count 10 restricts us to allow the audio only clips having maximum of 10 tracks, which may be acceptable.
  2547
+       */
  2548
+        if ((memCompRetVal) && (offsetToSeek < fileSize)) {
  2549
+            return true;
  2550
+        }
1869 2551
 
  2552
+        /*Vide handler was found!!!*/
  2553
+        *confidence = 0.4;
  2554
+
  2555
+        return true;
  2556
+    }
  2557
+}
  2558
+#else
1870 2559
 bool SniffMPEG4(
1871 2560
         const sp<DataSource> &source, String8 *mimeType, float *confidence,
1872 2561
         sp<AMessage> *) {
... ...
@@ -1881,6 +2570,6 @@ bool SniffMPEG4(
1881 2570
 
1882 2571
     return false;
1883 2572
 }
1884  
-
  2573
+#endif
1885 2574
 }  // namespace android
1886 2575
 
Txt media/libstagefright/MPEG4Writer.cpp 100644 → 100755
... ...
@@ -41,6 +41,10 @@ namespace android {
41 41
 static const int64_t kMax32BitFileSize = 0x007fffffffLL;
42 42
 static const uint8_t kNalUnitTypeSeqParamSet = 0x07;
43 43
 static const uint8_t kNalUnitTypePicParamSet = 0x08;
  44
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  45
+static const uint8_t kNalUnitTypeH264Sei = 0x06;
  46
+static const uint8_t kNalUnitTypeH264IFrame = 0x5;
  47
+#endif
44 48
 
45 49
 // Using longer adjustment period to suppress fluctuations in
46 50
 // the audio encoding paths
... ...
@@ -211,6 +215,19 @@ private:
211 215
 
212 216
     Track(const Track &);
213 217
     Track &operator=(const Track &);
  218
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  219
+    bool misOutofOrderTimestamps;
  220
+    struct TSTableEntry {
  221
+        TSTableEntry(uint32_t count, uint64_t timestampUs)
  222
+            : sampleCount(count), sampleTimestampUs(timestampUs) {}
  223
+        uint32_t sampleCount;
  224
+        uint64_t sampleTimestampUs;
  225
+    };
  226
+
  227
+    List<TSTableEntry> mPresentationTimeStamp;
  228
+    List<TSTableEntry> mDecodeTimeStamp;
  229
+    void sortPresentationTimestamp(List<TSTableEntry> &DecodingTS);
  230
+#endif
214 231
 };
215 232
 
216 233
 MPEG4Writer::MPEG4Writer(const char *filename)
... ...
@@ -714,6 +731,44 @@ static void StripStartcode(MediaBuffer *buffer) {
714 731
         return;
715 732
     }
716 733
 
  734
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP3)
  735
+    uint8_t *data =
  736
+        (uint8_t *)buffer->data() + buffer->range_offset();
  737
+    size_t size = buffer->range_length();
  738
+    uint8_t *tmp = data;
  739
+    uint8_t *foundStartData = data;
  740
+    size_t bytesLeft = size;
  741
+    size_t nal_size;
  742
+    bool foundStartCode = false;
  743
+
  744
+    while (bytesLeft > 4) {
  745
+        if (!memcmp("\x00\x00\x00\x01", tmp, 4)) {
  746
+            if (tmp - foundStartData) {
  747
+                if (foundStartCode == true) {
  748
+                    nal_size = tmp - foundStartData - 4;
  749
+                    foundStartData[0] = nal_size >> 24;
  750
+                    foundStartData[1] = (nal_size >> 16) & 0xFF;
  751
+                    foundStartData[2] = (nal_size >> 8) & 0xFF;
  752
+                    foundStartData[3] = nal_size & 0xFF;
  753
+                }
  754
+                foundStartData = tmp;
  755
+            }
  756
+            foundStartCode = true;
  757
+            tmp += 4;
  758
+            bytesLeft -= 4;
  759
+        } else {
  760
+            bytesLeft--;
  761
+            tmp++;
  762
+        }
  763
+    }
  764
+    if (foundStartCode == true) {
  765
+        nal_size = data + size - foundStartData - 4;
  766
+        foundStartData[0] = nal_size >> 24;
  767
+        foundStartData[1] = (nal_size >> 16) & 0xFF;
  768
+        foundStartData[2] = (nal_size >> 8) & 0xFF;
  769
+        foundStartData[3] = nal_size & 0xFF;
  770
+    }
  771
+#else
717 772
     const uint8_t *ptr =
718 773
         (const uint8_t *)buffer->data() + buffer->range_offset();
719 774
 
... ...
@@ -721,6 +776,7 @@ static void StripStartcode(MediaBuffer *buffer) {
721 776
         buffer->set_range(
722 777
                 buffer->range_offset() + 4, buffer->range_length() - 4);
723 778
     }
  779
+#endif
724 780
 }
725 781
 
726 782
 off_t MPEG4Writer::addLengthPrefixedSample_l(MediaBuffer *buffer) {
... ...
@@ -987,6 +1043,40 @@ void MPEG4Writer::Track::addOneSttsTableEntry(
987 1043
     mSttsTableEntries.push_back(sttsEntry);
988 1044
     ++mNumSttsTableEntries;
989 1045
 }
  1046
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1047
+void MPEG4Writer::Track::sortPresentationTimestamp(List<TSTableEntry> &DecodingTS)
  1048
+{
  1049
+    int i, j, flag = 1;    // set flag to 1 to start first pass
  1050
+    TSTableEntry temp(0,0);             // holding variable
  1051
+    size_t numLength = DecodingTS.size();
  1052
+    List<TSTableEntry>::iterator it = DecodingTS.begin();
  1053
+    List<TSTableEntry>::iterator ittemp1;
  1054
+    List<TSTableEntry>::iterator ittemp2;
  1055
+    //Initalize the variable to zero
  1056
+    //Out of order flag should be set for Bframe
  1057
+    //scenario. If this is set the ctts structure
  1058
+    //preparation is mandatory.
  1059
+    misOutofOrderTimestamps = 0;
  1060
+    it = DecodingTS.begin();
  1061
+    for(i = 1; (i <= numLength) && flag; i++) {
  1062
+        ittemp1 = it;
  1063
+        flag = 0;
  1064
+        for (j = 0; j < (numLength -1); j++) {
  1065
+            ittemp2 = ittemp1;
  1066
+            ittemp1 ++;
  1067
+            if (ittemp1->sampleTimestampUs < ittemp2->sampleTimestampUs){
  1068
+                temp = *ittemp2;             // swap elements
  1069
+                *ittemp2 = *ittemp1;
  1070
+                *ittemp1 = temp;
  1071
+                flag = 1;               // indicates that a swap occurred.
  1072
+                //This means that we have out of order
  1073
+                //timestamps and bframes are present
  1074
+                misOutofOrderTimestamps = 1;
  1075
+            }
  1076
+        }
  1077
+    }
  1078
+}
  1079
+#endif
990 1080
 
991 1081
 void MPEG4Writer::Track::addChunkOffset(off_t offset) {
992 1082
     ++mNumStcoTableEntries;
... ...
@@ -1103,9 +1193,13 @@ void MPEG4Writer::writeFirstChunk(ChunkInfo* info) {
1103 1193
     for (List<MediaBuffer *>::iterator it = chunkIt->mSamples.begin();
1104 1194
          it != chunkIt->mSamples.end(); ++it) {
1105 1195
 
  1196
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP3)
  1197
+        off_t offset = addSample_l(*it);
  1198
+#else
1106 1199
         off_t offset = info->mTrack->isAvc()
1107 1200
                             ? addLengthPrefixedSample_l(*it)
1108 1201
                             : addSample_l(*it);
  1202
+#endif
1109 1203
         if (it == chunkIt->mSamples.begin()) {
1110 1204
             info->mTrack->addChunkOffset(offset);
1111 1205
         }
... ...
@@ -1338,6 +1432,48 @@ static const uint8_t *findNextStartCode(
1338 1432
     return &data[length - bytesLeft];
1339 1433
 }
1340 1434
 
  1435
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1436
+static const uint16_t getLengthNalUnit(
  1437
+        const uint8_t *data, size_t length) {
  1438
+
  1439
+    LOGV("getLengthNalUnit: %p %d", data, length);
  1440
+
  1441
+    size_t bytesLeft = length;
  1442
+    uint16_t NalUnitLength = 0;
  1443
+    while (bytesLeft > 4  &&
  1444
+            memcmp("\x00\x00\x00\x01", &data[length - bytesLeft], 4)) {
  1445
+        --bytesLeft;
  1446
+        NalUnitLength++;
  1447
+    }
  1448
+    return (NalUnitLength + 4);
  1449
+}
  1450
+
  1451
+static void StripSpsPps(MediaBuffer *buffer) {
  1452
+   const uint8_t *ptr = (const uint8_t *)buffer->data() + buffer->range_offset();
  1453
+   const uint8_t *nextStartCode = ptr;
  1454
+   size_t bytesLeft = buffer->range_length();
  1455
+   uint8_t type = 0;
  1456
+   uint16_t nalLength = 0;
  1457
+
  1458
+    while (bytesLeft > 4 && !memcmp("\x00\x00\x00\x01", ptr, 4)) {
  1459
+        getNalUnitType(*(ptr + 4), &type);
  1460
+        if (type == kNalUnitTypeH264IFrame) {
  1461
+            LOGV("Got the sync frame. Break out.");
  1462
+            break;
  1463
+        }
  1464
+        // Strip SPS, PPS or SEI info if any
  1465
+        else if (type == kNalUnitTypeSeqParamSet || type == kNalUnitTypePicParamSet ) {
  1466
+            nalLength = getLengthNalUnit(ptr+4,bytesLeft-4);
  1467
+            LOGV("Stripping Nal Type 0x%x, Nal-Length %d",type,nalLength);
  1468
+            buffer->set_range(buffer->range_offset() + nalLength, buffer->range_length() - nalLength);
  1469
+        }
  1470
+        nextStartCode = findNextStartCode(ptr+4,bytesLeft-4);
  1471
+        bytesLeft -= nextStartCode - ptr;
  1472
+        ptr = nextStartCode;
  1473
+    }
  1474
+}
  1475
+#endif
  1476
+
1341 1477
 const uint8_t *MPEG4Writer::Track::parseParamSet(
1342 1478
         const uint8_t *data, size_t length, int type, size_t *paramSetLen) {
1343 1479
 
... ...
@@ -1474,8 +1610,13 @@ status_t MPEG4Writer::Track::parseAVCCodecSpecificData(
1474 1610
     {
1475 1611
         // Check on the profiles
1476 1612
         // These profiles requires additional parameter set extensions
  1613
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1614
+
  1615
+        if (mProfileIdc == 110 || mProfileIdc == 122 || mProfileIdc == 144) {
  1616
+#else
1477 1617
         if (mProfileIdc == 100 || mProfileIdc == 110 ||
1478 1618
             mProfileIdc == 122 || mProfileIdc == 144) {
  1619
+#endif
1479 1620
             LOGE("Sorry, no support for profile_idc: %d!", mProfileIdc);
1480 1621
             return BAD_VALUE;
1481 1622
         }
... ...
@@ -1710,6 +1851,10 @@ status_t MPEG4Writer::Track::threadEntry() {
1710 1851
     uint32_t previousSampleSize = 0;  // Size of the previous sample
1711 1852
     int64_t previousPausedDurationUs = 0;
1712 1853
     int64_t timestampUs;
  1854
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  1855
+    uint8_t *copy_spspps;
  1856
+    int32_t copy_spspps_size = 0;
  1857
+#endif
1713 1858
 
1714 1859
     if (mIsAudio) {
1715 1860
         prctl(PR_SET_NAME, (unsigned long)"AudioTrackEncoding", 0, 0, 0);
... ...
@@ -1766,20 +1911,112 @@ status_t MPEG4Writer::Track::threadEntry() {
1766 1911
             mGotAllCodecSpecificData = true;
1767 1912
             continue;
1768 1913
         }
  1914
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  1915
+        else if (mIsAvc && count < 3) {
  1916
+            size_t size = buffer->range_length();
  1917
+            size_t start_code_size = 0;
  1918
+
  1919
+            CHECK(!mGotAllCodecSpecificData);
  1920
+
  1921
+            start_code_size = memcmp("\x00\x00\x00\x01",
  1922
+                    (uint8_t *)buffer->data(), 4) ? 4 : 0;
  1923
+
  1924
+            switch (count) {
  1925
+                case 1:
  1926
+                {
  1927
+                    copy_spspps = (uint8_t *)malloc(size + start_code_size);
  1928
+                    copy_spspps_size = size + start_code_size;
  1929
+                    if (start_code_size)
  1930
+                        memcpy(copy_spspps,
  1931
+                                "\x00\x00\x00\x01", start_code_size);
  1932
+                    memcpy((uint8_t *)copy_spspps + start_code_size,
  1933
+                            (const uint8_t *)buffer->data()
  1934
+                                + buffer->range_offset(),
  1935
+                            size);
  1936
+                    break;
  1937
+                }
  1938
+
  1939
+                case 2:
  1940
+                {
  1941
+                    size_t offset = copy_spspps_size;
  1942
+                    copy_spspps_size += (size + start_code_size);
  1943
+                    copy_spspps = (uint8_t *)realloc(copy_spspps, copy_spspps_size);
  1944
+                    if (start_code_size)
  1945
+                        memcpy(&copy_spspps[offset],
  1946
+                                "\x00\x00\x00\x01", start_code_size);
  1947
+                    memcpy(&copy_spspps[offset + start_code_size],
  1948
+                            (const uint8_t *)buffer->data()
  1949
+                                + buffer->range_offset(),
  1950
+                            size);
  1951
+                    status_t err = makeAVCCodecSpecificData(
  1952
+                            copy_spspps, copy_spspps_size);
  1953
+                    CHECK_EQ(OK, err);
  1954
+                    free(copy_spspps);
  1955
+                    copy_spspps = NULL;
  1956
+                    mGotAllCodecSpecificData = true;
  1957
+                    break;
  1958
+                }
  1959
+            }
  1960
+
  1961
+            buffer->release();
  1962
+            buffer = NULL;
  1963
+
  1964
+            continue;
  1965
+
  1966
+        } else if (mCodecSpecificData == NULL && mIsMPEG4) {
  1967
+            CHECK(!mGotAllCodecSpecificData);
  1968
+            mCodecSpecificDataSize = buffer->range_length();
  1969
+            mCodecSpecificData = malloc(mCodecSpecificDataSize);
  1970
+            memcpy(mCodecSpecificData,
  1971
+                    (const uint8_t *)buffer->data()
  1972
+                        + buffer->range_offset(),
  1973
+                   buffer->range_length());
  1974
+            buffer->release();
  1975
+            buffer = NULL;
  1976
+
  1977
+            mGotAllCodecSpecificData = true;
  1978
+            continue;
  1979
+        }
  1980
+#endif
1769 1981
 
1770 1982
         // Make a deep copy of the MediaBuffer and Metadata and release
1771 1983
         // the original as soon as we can
  1984
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP3)
  1985
+        MediaBuffer *copy;
  1986
+        size_t start_code_size = 0;
  1987
+
  1988
+        if (mIsAvc) {
  1989
+            start_code_size = memcmp("\x00\x00\x00\x01",
  1990
+                    (uint8_t *)buffer->data(), 4) ? 4 : 0;
  1991
+        }
  1992
+        copy = new MediaBuffer(buffer->range_length() + start_code_size);
  1993
+        if (start_code_size)
  1994
+            memcpy(copy->data(), "\x00\x00\x00\x01", start_code_size);
  1995
+        memcpy((uint8_t *)copy->data() + start_code_size,
  1996
+                (uint8_t *)buffer->data() + buffer->range_offset(),
  1997
+                buffer->range_length());
  1998
+        copy->set_range(0, buffer->range_length() + start_code_size);
  1999
+#else
1772 2000
         MediaBuffer *copy = new MediaBuffer(buffer->range_length());
1773 2001
         memcpy(copy->data(), (uint8_t *)buffer->data() + buffer->range_offset(),
1774 2002
                 buffer->range_length());
1775 2003
         copy->set_range(0, buffer->range_length());
  2004
+#endif
1776 2005
         meta_data = new MetaData(*buffer->meta_data().get());
1777 2006
         buffer->release();
1778 2007
         buffer = NULL;
1779 2008
 
  2009
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  2010
+        int32_t isSync1 = 0;
  2011
+        meta_data->findInt32(kKeyIsSyncFrame, &isSync1);
  2012
+
  2013
+        if (mIsAvc && isSync1) StripSpsPps(copy);
  2014
+#endif
  2015
+
1780 2016
         if (mIsAvc) StripStartcode(copy);
1781 2017
 
1782 2018
         size_t sampleSize = copy->range_length();
  2019
+#if !defined (OMAP_ENHANCEMENT) || !defined (TARGET_OMAP3)
1783 2020
         if (mIsAvc) {
1784 2021
             if (mOwner->useNalLengthFour()) {
1785 2022
                 sampleSize += 4;
... ...
@@ -1787,6 +2024,7 @@ status_t MPEG4Writer::Track::threadEntry() {
1787 2024
                 sampleSize += 2;
1788 2025
             }
1789 2026
         }
  2027
+#endif
1790 2028
 
1791 2029
         // Max file size or duration handling
1792 2030
         mMdatSizeBytes += sampleSize;
... ...
@@ -1863,6 +2101,7 @@ status_t MPEG4Writer::Track::threadEntry() {
1863 2101
 
1864 2102
         CHECK(timestampUs >= 0);
1865 2103
         if (mNumSamples > 1) {
  2104
+#if !defined(OMAP_ENHANCEMENT) && !defined(TARGET_OMAP4)
1866 2105
             if (timestampUs <= lastTimestampUs) {
1867 2106
                 LOGW("Frame arrives too late!");
1868 2107
                 // Don't drop the late frame, since dropping a frame may cause
... ...
@@ -1876,6 +2115,7 @@ status_t MPEG4Writer::Track::threadEntry() {
1876 2115
                     timestampUs = lastTimestampUs + (1000000LL + (mTimeScale >> 1)) / mTimeScale;
1877 2116
                 }
1878 2117
             }
  2118
+#endif
1879 2119
         }
1880 2120
 
1881 2121
         LOGV("%s media time stamp: %lld and previous paused duration %lld",
... ...
@@ -1897,7 +2137,18 @@ status_t MPEG4Writer::Track::threadEntry() {
1897 2137
                      (lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);
1898 2138
 
1899 2139
             if (currDurationTicks != lastDurationTicks) {
  2140
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2141
+            if(!mIsAudio) {
  2142
+                //Collect timestamps
  2143
+                TSTableEntry sample(sampleCount,lastTimestampUs);
  2144
+                mPresentationTimeStamp.push_back(sample);
  2145
+                mDecodeTimeStamp.push_back(sample);
  2146
+            } else {
1900 2147
                 addOneSttsTableEntry(sampleCount, lastDurationUs);
  2148
+            }
  2149
+#else
  2150
+                addOneSttsTableEntry(sampleCount, lastDurationUs);
  2151
+#endif
1901 2152
                 sampleCount = 1;
1902 2153
             } else {
1903 2154
                 ++sampleCount;
... ...
@@ -1924,8 +2175,12 @@ status_t MPEG4Writer::Track::threadEntry() {
1924 2175
             trackProgressStatus(timestampUs);
1925 2176
         }
1926 2177
         if (mOwner->numTracks() == 1) {
  2178
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP3)
  2179
+            off_t offset = mOwner->addSample_l(copy);
  2180
+#else
1927 2181
             off_t offset = mIsAvc? mOwner->addLengthPrefixedSample_l(copy)
1928 2182
                                  : mOwner->addSample_l(copy);
  2183
+#endif
1929 2184
             if (mChunkOffsets.empty()) {
1930 2185
                 addChunkOffset(offset);
1931 2186
             }
... ...
@@ -1980,7 +2235,19 @@ status_t MPEG4Writer::Track::threadEntry() {
1980 2235
     } else {
1981 2236
         ++sampleCount;  // Count for the last sample
1982 2237
     }
  2238
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2239
+    if(!mIsAudio) {
  2240
+        //Collect timestamps
  2241
+        TSTableEntry sample(sampleCount,lastTimestampUs);
  2242
+        mPresentationTimeStamp.push_back(sample);
  2243
+        mDecodeTimeStamp.push_back(sample);
  2244
+    } else {
  2245
+        addOneSttsTableEntry(sampleCount, lastDurationUs);
  2246
+    }
  2247
+#else
1983 2248
     addOneSttsTableEntry(sampleCount, lastDurationUs);
  2249
+#endif
  2250
+
1984 2251
     mTrackDurationUs += lastDurationUs;
1985 2252
     mReachedEOS = true;
1986 2253
     LOGI("Received total/0-length (%d/%d) buffers and encoded %d frames. - %s",
... ...
@@ -2413,6 +2680,37 @@ void MPEG4Writer::Track::writeTrackHeader(
2413 2680
           mOwner->endBox();  // stsd
2414 2681
 
2415 2682
           mOwner->beginBox("stts");
  2683
+
  2684
+ #if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2685
+            if(!mIsAudio) { // ctts is valid only for video
  2686
+
  2687
+                //Make sure that the Stts value is sorted and
  2688
+                //is in increasing order. As per standard stts
  2689
+                //cannot be negative so unless we sort the out
  2690
+                //of order timestamp the duration encoding will
  2691
+                //not be positive.
  2692
+                // stts[n] = dts[n+1] - dts[n]
  2693
+                sortPresentationTimestamp(mDecodeTimeStamp);
  2694
+
  2695
+                //Need to add First frame time stamp as zero
  2696
+                //for the Iframe encoding
  2697
+                TSTableEntry temp (1,0);
  2698
+                mDecodeTimeStamp.push_front(temp);
  2699
+
  2700
+                //Update the duration in stts stucture.
  2701
+                uint32_t countDecodeTSList = mDecodeTimeStamp.size();
  2702
+                List<TSTableEntry>::iterator itcur = mDecodeTimeStamp.begin();
  2703
+                List<TSTableEntry>::iterator itnext = itcur;
  2704
+                itnext ++;
  2705
+                for (uint32_t i = 1; i < countDecodeTSList; i++) {
  2706
+                    addOneSttsTableEntry(itnext->sampleCount, (itnext->sampleTimestampUs - itcur->sampleTimestampUs) / itnext->sampleCount);
  2707
+                    itnext ++;
  2708
+                    itcur ++;
  2709
+                }
  2710
+
  2711
+            }
  2712
+ #endif
  2713
+
2416 2714
             mOwner->writeInt32(0);  // version=0, flags=0
2417 2715
             mOwner->writeInt32(mNumSttsTableEntries);
2418 2716
             int64_t prevTimestampUs = 0;
... ...
@@ -2431,6 +2729,33 @@ void MPEG4Writer::Track::writeTrackHeader(
2431 2729
             }
2432 2730
           mOwner->endBox();  // stts
2433 2731
 
  2732
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2733
+        if(!mIsAudio && misOutofOrderTimestamps) {
  2734
+            LOGE("Out of order detected!");
  2735
+            mOwner->beginBox("ctts");
  2736
+            mOwner->writeInt32(0);  // version=0, flags=0
  2737
+            mOwner->writeInt32(mDecodeTimeStamp.size());
  2738
+
  2739
+            // Write first sample for Iframe as zero
  2740
+            mOwner->writeInt32(1);
  2741
+            mOwner->writeInt32(0);
  2742
+
  2743
+            // Encode the offset of ctts as difference between presentation timestamp
  2744
+            // and decoding timestamp.
  2745
+            size_t countPresentationTSList = mPresentationTimeStamp.size();
  2746
+            List<TSTableEntry>::iterator itpresentation = mPresentationTimeStamp.begin();
  2747
+            List<TSTableEntry>::iterator itdecoding     = mDecodeTimeStamp.begin();
  2748
+            for (size_t i = 0; i < countPresentationTSList; ++i) {
  2749
+                mOwner->writeInt32(itdecoding->sampleCount);
  2750
+                int32_t dur =  ((itpresentation->sampleTimestampUs * mTimeScale + 500000LL) / 1000000LL -
  2751
+                             (itdecoding->sampleTimestampUs * mTimeScale + 500000LL) / 1000000LL);
  2752
+                itpresentation ++;
  2753
+                itdecoding ++;
  2754
+                mOwner->writeInt32(dur);
  2755
+            }
  2756
+          mOwner->endBox();  // ctts
  2757
+        }
  2758
+#endif
2434 2759
           if (!mIsAudio) {
2435 2760
             mOwner->beginBox("stss");
2436 2761
               mOwner->writeInt32(0);  // version=0, flags=0
Txt media/libstagefright/MediaBuffer.cpp
... ...
@@ -112,10 +112,25 @@ size_t MediaBuffer::range_length() const {
112 112
 }
113 113
 
114 114
 void MediaBuffer::set_range(size_t offset, size_t length) {
  115
+#ifdef OMAP_ENHANCEMENT
  116
+    if(offset) {
  117
+        if (offset + length > mSize) {
  118
+            LOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
  119
+        }
  120
+        CHECK(offset + length <= mSize);
  121
+    }
  122
+    else {
  123
+        if (length > mSize) {
  124
+            LOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
  125
+            length = mSize;
  126
+        }
  127
+    }
  128
+#else
115 129
     if (offset + length > mSize) {
116 130
         LOGE("offset = %d, length = %d, mSize = %d", offset, length, mSize);
117 131
     }
118 132
     CHECK(offset + length <= mSize);
  133
+#endif
119 134
 
120 135
     mRangeOffset = offset;
121 136
     mRangeLength = length;
Txt media/libstagefright/MediaDefs.cpp
... ...
@@ -25,6 +25,17 @@ const char *MEDIA_MIMETYPE_VIDEO_AVC = "video/avc";
25 25
 const char *MEDIA_MIMETYPE_VIDEO_MPEG4 = "video/mp4v-es";
26 26
 const char *MEDIA_MIMETYPE_VIDEO_H263 = "video/3gpp";
27 27
 const char *MEDIA_MIMETYPE_VIDEO_RAW = "video/raw";
  28
+#if defined(OMAP_ENHANCEMENT)
  29
+#if  defined(TARGET_OMAP4)
  30
+const char *MEDIA_MIMETYPE_VIDEO_VP6 = "video/x-vp6";
  31
+const char *MEDIA_MIMETYPE_VIDEO_VP7 = "video/x-vp7";
  32
+#endif
  33
+const char *MEDIA_MIMETYPE_CONTAINER_ASF = "video/asf";
  34
+const char *MEDIA_MIMETYPE_VIDEO_WMV  = "video/wmv9";
  35
+const char *MEDIA_MIMETYPE_AUDIO_WMA = "audio/wma";
  36
+const char *MEDIA_MIMETYPE_AUDIO_WMAPRO = "audio/wmapro";
  37
+const char *MEDIA_MIMETYPE_AUDIO_WMALSL = "audio/wmalsl";
  38
+#endif
28 39
 
29 40
 const char *MEDIA_MIMETYPE_AUDIO_AMR_NB = "audio/3gpp";
30 41
 const char *MEDIA_MIMETYPE_AUDIO_AMR_WB = "audio/amr-wb";
... ...
@@ -39,7 +50,11 @@ const char *MEDIA_MIMETYPE_AUDIO_RAW = "audio/raw";
39 50
 const char *MEDIA_MIMETYPE_CONTAINER_MPEG4 = "video/mpeg4";
40 51
 const char *MEDIA_MIMETYPE_CONTAINER_WAV = "audio/wav";
41 52
 const char *MEDIA_MIMETYPE_CONTAINER_OGG = "application/ogg";
  53
+
42 54
 const char *MEDIA_MIMETYPE_CONTAINER_MATROSKA = "video/x-matroska";
43 55
 const char *MEDIA_MIMETYPE_CONTAINER_MPEG2TS = "video/mp2ts";
44 56
 
  57
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  58
+const char *MEDIA_MIMETYPE_CONTAINER_AVI = "video/x-msvideo";
  59
+#endif
45 60
 }  // namespace android
Txt media/libstagefright/MediaExtractor.cpp
... ...
@@ -34,6 +34,10 @@
34 34
 #include <media/stagefright/MetaData.h>
35 35
 #include <utils/String8.h>
36 36
 
  37
+#ifdef OMAP_ENHANCEMENT
  38
+#include "include/ASFExtractor.h"
  39
+#endif
  40
+
37 41
 namespace android {
38 42
 
39 43
 sp<MetaData> MediaExtractor::getMetaData() {
... ...
@@ -80,6 +84,16 @@ sp<MediaExtractor> MediaExtractor::Create(
80 84
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) {
81 85
         return new MPEG2TSExtractor(source);
82 86
     }
  87
+#ifdef OMAP_ENHANCEMENT
  88
+    else if(!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_ASF)) {
  89
+        if(isASFParserAvailable()) {
  90
+            return new ASFExtractor(source);
  91
+        }
  92
+        else {
  93
+            return NULL;
  94
+        }
  95
+    }
  96
+#endif
83 97
 
84 98
     return NULL;
85 99
 }
Txt media/libstagefright/MediaSource.cpp
... ...
@@ -37,10 +37,23 @@ void MediaSource::ReadOptions::reset() {
37 37
 
38 38
 void MediaSource::ReadOptions::setSeekTo(int64_t time_us, SeekMode mode) {
39 39
     mOptions |= kSeekTo_Option;
  40
+#ifdef OMAP_ENHANCEMENT
  41
+    //Incase the app layer tries to seek to negative offset,
  42
+    //resetting the value to Zero.
  43
+    if (time_us < 0)
  44
+    {
  45
+        time_us = 0;
  46
+    }
  47
+#endif
40 48
     mSeekTimeUs = time_us;
41 49
     mSeekMode = mode;
42 50
 }
43 51
 
  52
+extern "C" void _ZN7android11MediaSource11ReadOptions9setSeekToExNS1_8SeekModeE(int64_t time_us, void *mode);
  53
+extern "C" void _ZN7android11MediaSource11ReadOptions9setSeekToEx(int64_t time_us) {
  54
+    _ZN7android11MediaSource11ReadOptions9setSeekToExNS1_8SeekModeE(time_us, NULL);
  55
+}
  56
+
44 57
 void MediaSource::ReadOptions::clearSeekTo() {
45 58
     mOptions &= ~kSeekTo_Option;
46 59
     mSeekTimeUs = 0;
Txt media/libstagefright/NuCachedSource2.cpp 100644 → 100755
... ...
@@ -327,7 +327,11 @@ void NuCachedSource2::onRead(const sp<AMessage> &msg) {
327 327
 }
328 328
 
329 329
 void NuCachedSource2::restartPrefetcherIfNecessary_l(bool force) {
  330
+#ifndef OMAP_ENHANCEMENT
330 331
     static const size_t kGrayArea = 256 * 1024;
  332
+#else
  333
+    static const size_t kGrayArea = 256 * 1024 * 12;
  334
+#endif
331 335
 
332 336
     if (mFetching || mFinalStatus != OK) {
333 337
         return;
... ...
@@ -435,8 +439,12 @@ ssize_t NuCachedSource2::readInternal(off_t offset, void *data, size_t size) {
435 439
 
436 440
     if (offset < mCacheOffset
437 441
             || offset >= (off_t)(mCacheOffset + mCache->totalSize())) {
  442
+#ifndef OMAP_ENHANCEMENT
438 443
         static const off_t kPadding = 32768;
439  
-
  444
+#else
  445
+        // make this value larger for high profile playback
  446
+        static const off_t kPadding = 768 * 1024;
  447
+#endif
440 448
         // In the presence of multiple decoded streams, once of them will
441 449
         // trigger this seek request, the other one will request data "nearby"
442 450
         // soon, adjust the seek position so that that subsequent request
... ...
@@ -447,6 +455,13 @@ ssize_t NuCachedSource2::readInternal(off_t offset, void *data, size_t size) {
447 455
     }
448 456
 
449 457
     size_t delta = offset - mCacheOffset;
  458
+#ifdef OMAP_ENHANCEMENT
  459
+    if (offset + size <= mCacheOffset + mCache->totalSize()) {
  460
+        mCache->copy(delta, data, size);
  461
+
  462
+        return size;
  463
+    }
  464
+#endif
450 465
 
451 466
     if (mFinalStatus != OK) {
452 467
         if (delta >= mCache->totalSize()) {
... ...
@@ -459,11 +474,13 @@ ssize_t NuCachedSource2::readInternal(off_t offset, void *data, size_t size) {
459 474
         return avail;
460 475
     }
461 476
 
  477
+#ifndef OMAP_ENHANCEMENT
462 478
     if (offset + size <= mCacheOffset + mCache->totalSize()) {
463 479
         mCache->copy(delta, data, size);
464 480
 
465 481
         return size;
466 482
     }
  483
+#endif
467 484
 
468 485
     LOGV("deferring read");
469 486
 
Txt media/libstagefright/OMXCodec.cpp
... ...
@@ -35,6 +35,10 @@
35 35
 
36 36
 #include "include/ESDS.h"
37 37
 
  38
+#if defined(OMAP_ENHANCEMENT) && (TARGET_OMAP4)
  39
+#define NPA_BUFFERS
  40
+#endif
  41
+
38 42
 #include <binder/IServiceManager.h>
39 43
 #include <binder/MemoryDealer.h>
40 44
 #include <binder/ProcessState.h>
... ...
@@ -60,6 +64,79 @@
60 64
 #endif
61 65
 
62 66
 #include "include/ThreadedSource.h"
  67
+#ifdef OMAP_ENHANCEMENT
  68
+#include <overlay_common.h>
  69
+#include <cutils/properties.h>
  70
+#ifdef TARGET_OMAP4
  71
+#include <TICameraParameters.h>
  72
+
  73
+#include "OMX_TI_Index.h"
  74
+#include "OMX_TI_Common.h"
  75
+#include "OMX_TI_Video.h"
  76
+#include "OMX_TI_IVCommon.h"
  77
+#endif
  78
+
  79
+/**
  80
+* Important Note#
  81
+* Method to calculate the reference frames required for decoder on output port
  82
+* This is as per standard, hence no changes are expected in this function logic in the future
  83
+* But for any changes done inside Codec, it is required to update here as well as in
  84
+* TIHardwareRenderer.cpp (platform/hardware/ti/omap3/libstagefrighthw)
  85
+* And this will be removed once flash backward compatibity issue is resolved.
  86
+*/
  87
+static int Calculate_TotalRefFrames(int nWidth, int nHeight) {
  88
+    LOGD("Calculate_TotalRefFrames");
  89
+    uint32_t ref_frames = 0;
  90
+    uint32_t MaxDpbMbs;
  91
+    uint32_t PicWidthInMbs;
  92
+    uint32_t FrameHeightInMbs;
  93
+
  94
+    MaxDpbMbs = 32768; //Maximum value for upto level 4.1
  95
+
  96
+    PicWidthInMbs = nWidth / 16;
  97
+
  98
+    FrameHeightInMbs = nHeight / 16;
  99
+
  100
+    ref_frames =  (uint32_t)(MaxDpbMbs / (PicWidthInMbs * FrameHeightInMbs));
  101
+
  102
+    LOGD("nWidth [%d] PicWidthInMbs [%d] nHeight [%d] FrameHeightInMbs [%d] ref_frames [%d]",
  103
+          nWidth, PicWidthInMbs, nHeight, FrameHeightInMbs, ref_frames);
  104
+
  105
+    ref_frames = (ref_frames > 16) ? 16 : ref_frames;
  106
+
  107
+    LOGD("Final ref_frames [%d]",  ref_frames);
  108
+
  109
+    return (ref_frames + 3 + 2*NUM_BUFFERS_TO_BE_QUEUED_FOR_OPTIMAL_PERFORMANCE);
  110
+}
  111
+
  112
+#if defined NPA_BUFFERS
  113
+#define OMX_BUFFERHEADERFLAG_MODIFIED 0x00000100
  114
+#define THUMBNAIL_BUFFERS_NPA_MODE 2
  115
+#define NPA_BUFFER_SIZE 4
  116
+#endif
  117
+
  118
+#ifdef TARGET_OMAP4
  119
+#define SUPPORT_B_FRAMES
  120
+#ifdef SUPPORT_B_FRAMES
  121
+#define OMX_NUM_B_FRAMES 2
  122
+#else
  123
+#define OMX_NUM_B_FRAMES 0
  124
+#endif
  125
+#define OUTPUT_BUFFER_COUNT 2
  126
+#define INPUT_BUFFER_COUNT 2
  127
+#elif defined(TARGET_OMAP3)
  128
+#if defined(OVERLAY_NUM_REQBUFFERS)
  129
+#define OUTPUT_BUFFER_COUNT OVERLAY_NUM_REQBUFFERS
  130
+#else
  131
+#define OUTPUT_BUFFER_COUNT 4
  132
+#endif
  133
+#endif
  134
+
  135
+#endif
  136
+
  137
+#ifdef OMAP_ENHANCEMENT
  138
+#include <overlay_common.h>
  139
+#endif
63 140
 
64 141
 namespace android {
65 142
 
... ...
@@ -157,6 +234,78 @@ static sp<MediaSource> InstantiateSoftwareCodec(
157 234
 #undef FACTORY_REF
158 235
 #undef FACTORY_CREATE
159 236
 
  237
+#ifdef OMAP_ENHANCEMENT
  238
+#ifdef TARGET_OMAP4
  239
+//Enable Ducati Codecs for Video, PV SW codecs for Audio
  240
+static const CodecInfo kDecoderInfo[] = {
  241
+    { MEDIA_MIMETYPE_AUDIO_MPEG, "MP3Decoder" },
  242
+    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "AMRNBDecoder" },
  243
+    { MEDIA_MIMETYPE_AUDIO_AMR_WB, "AMRWBDecoder" },
  244
+    { MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder" },
  245
+    { MEDIA_MIMETYPE_VIDEO_WMV, "OMX.TI.DUCATI1.VIDEO.DECODER" },
  246
+    { MEDIA_MIMETYPE_AUDIO_WMA, "OMX.ITTIAM.WMA.decode" },
  247
+    { MEDIA_MIMETYPE_AUDIO_WMALSL, "OMX.ITTIAM.WMALSL.decode" },
  248
+    { MEDIA_MIMETYPE_AUDIO_WMAPRO, "OMX.ITTIAM.WMAPRO.decode" },
  249
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.DUCATI1.VIDEO.DECODER" },
  250
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "M4vH263Decoder" },
  251
+    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.DUCATI1.VIDEO.DECODER" },
  252
+    { MEDIA_MIMETYPE_VIDEO_H263, "M4vH263Decoder" },
  253
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.DUCATI1.VIDEO.DECODER" },
  254
+    { MEDIA_MIMETYPE_VIDEO_AVC, "AVCDecoder" },
  255
+    { MEDIA_MIMETYPE_AUDIO_VORBIS, "VorbisDecoder" },
  256
+    { MEDIA_MIMETYPE_VIDEO_VP6, "OMX.TI.DUCATI1.VIDEO.DECODER" },
  257
+    { MEDIA_MIMETYPE_VIDEO_VP7, "OMX.TI.DUCATI1.VIDEO.DECODER" }
  258
+};
  259
+
  260
+//Maintain only s/w encoders till ducati encoders are integrated to SF
  261
+static const CodecInfo kEncoderInfo[] = {
  262
+    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "AMRNBEncoder" },
  263
+    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.ITTIAM.AAC.encode" },
  264
+    { MEDIA_MIMETYPE_AUDIO_AAC, "AACEncoder" },
  265
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.DUCATI1.VIDEO.MPEG4E" },
  266
+    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.DUCATI1.VIDEO.MPEG4E" },
  267
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.DUCATI1.VIDEO.H264E" },
  268
+};
  269
+#elif defined(TARGET_OMAP3)
  270
+static const CodecInfo kDecoderInfo[] = {
  271
+    { MEDIA_MIMETYPE_IMAGE_JPEG, "OMX.TI.JPEG.decode" },
  272
+    { MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.TI.MP3.decode" },
  273
+    { MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.PV.mp3dec" },
  274
+    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.TI.AMR.decode" },
  275
+    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.PV.amrdec" },
  276
+    { MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.TI.WBAMR.decode" },
  277
+    { MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.PV.amrdec" },
  278
+    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.decode" },
  279
+    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.ITTIAM.AAC.decode" },
  280
+    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.PV.aacdec" },
  281
+    { MEDIA_MIMETYPE_AUDIO_AAC, "AACDecoder" },
  282
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.Decoder" },
  283
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.720P.Decoder" },
  284
+    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.Video.Decoder" },
  285
+    /* 720p Video Decoder must be placed before the TI Video Decoder.
  286
+       DO NOT CHANGE THIS SEQUENCE. IT WILL BREAK FLASH. */
  287
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.720P.Decoder" },
  288
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.Video.Decoder" },
  289
+    { MEDIA_MIMETYPE_AUDIO_VORBIS, "VorbisDecoder" },
  290
+    { MEDIA_MIMETYPE_VIDEO_WMV, "OMX.TI.Video.Decoder" },
  291
+    { MEDIA_MIMETYPE_VIDEO_WMV, "OMX.TI.720P.Decoder" },
  292
+    { MEDIA_MIMETYPE_AUDIO_WMA, "OMX.TI.WMA.decode"},
  293
+    { MEDIA_MIMETYPE_AUDIO_WMA, "OMX.ITTIAM.WMA.decode"},
  294
+};
  295
+
  296
+static const CodecInfo kEncoderInfo[] = {
  297
+    { MEDIA_MIMETYPE_AUDIO_AMR_NB, "OMX.TI.AMR.encode" },
  298
+    { MEDIA_MIMETYPE_AUDIO_AMR_WB, "OMX.TI.WBAMR.encode" },
  299
+    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.TI.AAC.encode" },
  300
+    { MEDIA_MIMETYPE_AUDIO_AAC, "OMX.ITTIAM.AAC.encode" },
  301
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.Video.encoder" },
  302
+    { MEDIA_MIMETYPE_VIDEO_MPEG4, "OMX.TI.720P.Encoder" },
  303
+    { MEDIA_MIMETYPE_VIDEO_H263, "OMX.TI.Video.encoder" },
  304
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.Video.encoder" },
  305
+    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.TI.720P.Encoder" },
  306
+};
  307
+#endif
  308
+#else
160 309
 static const CodecInfo kDecoderInfo[] = {
161 310
     { MEDIA_MIMETYPE_IMAGE_JPEG, "OMX.TI.JPEG.decode" },
162 311
     { MEDIA_MIMETYPE_AUDIO_MPEG, "OMX.Nvidia.mp3.decoder" },
... ...
@@ -233,6 +382,7 @@ static const CodecInfo kEncoderInfo[] = {
233 382
     { MEDIA_MIMETYPE_VIDEO_AVC, "AVCEncoder" },
234 383
 //    { MEDIA_MIMETYPE_VIDEO_AVC, "OMX.PV.avcenc" },
235 384
 };
  385
+#endif
236 386
 
237 387
 #undef OPTIONAL
238 388
 
... ...
@@ -240,6 +390,19 @@ static const CodecInfo kEncoderInfo[] = {
240 390
 #define CODEC_LOGV(x, ...) LOGV("[%s] "x, mComponentName, ##__VA_ARGS__)
241 391
 #define CODEC_LOGE(x, ...) LOGE("[%s] "x, mComponentName, ##__VA_ARGS__)
242 392
 
  393
+#ifdef OMAP_ENHANCEMENT
  394
+/* This flag has to be updated according to the Memory dealer cache line
  395
+ * alignment value "SimpleBestFitAllocator::kMemoryAlign"
  396
+ * It is required to allocate correct amount of memory considering the
  397
+ * alignment, Otherwise alloc fails when input buffer sizes are not aligned*/
  398
+#ifdef TARGET_OMAP4
  399
+#define CACHELINE_BOUNDARY_MEMALIGNMENT 32
  400
+#else
  401
+#define CACHELINE_BOUNDARY_MEMALIGNMENT 128
  402
+#endif
  403
+#endif
  404
+
  405
+#ifndef OMAP_ENHANCEMENT
243 406
 struct OMXCodecObserver : public BnOMXObserver {
244 407
     OMXCodecObserver() {
245 408
     }
... ...
@@ -275,6 +438,7 @@ private:
275 438
     OMXCodecObserver(const OMXCodecObserver &);
276 439
     OMXCodecObserver &operator=(const OMXCodecObserver &);
277 440
 };
  441
+#endif
278 442
 
279 443
 static const char *GetCodec(const CodecInfo *info, size_t numInfos,
280 444
                             const char *mime, int index) {
... ...
@@ -325,6 +489,7 @@ static const char *AVCProfileToString(uint8_t profile) {
325 489
     }
326 490
 }
327 491
 
  492
+#ifndef OMAP_ENHANCEMENT
328 493
 template<class T>
329 494
 static void InitOMXParams(T *params) {
330 495
     params->nSize = sizeof(T);
... ...
@@ -333,6 +498,7 @@ static void InitOMXParams(T *params) {
333 498
     params->nVersion.s.nRevision = 0;
334 499
     params->nVersion.s.nStep = 0;
335 500
 }
  501
+#endif
336 502
 
337 503
 static bool IsSoftwareCodec(const char *componentName) {
338 504
     if (!strncmp("OMX.PV.", componentName, 7)) {
... ...
@@ -374,8 +540,12 @@ static int CompareSoftwareCodecsFirst(
374 540
 }
375 541
 
376 542
 // static
  543
+#ifdef OMAP_ENHANCEMENT
  544
+uint32_t OMXCodec::getComponentQuirks(const char *componentName,bool isEncoder, uint32_t flags) {
  545
+#else
377 546
 uint32_t OMXCodec::getComponentQuirks(
378 547
         const char *componentName, bool isEncoder) {
  548
+#endif
379 549
     uint32_t quirks = 0;
380 550
 
381 551
     if (!strcmp(componentName, "OMX.PV.avcdec")) {
... ...
@@ -392,12 +562,43 @@ uint32_t OMXCodec::getComponentQuirks(
392 562
     if (!strcmp(componentName, "OMX.TI.MP3.decode")) {
393 563
         quirks |= kNeedsFlushBeforeDisable;
394 564
         quirks |= kDecoderLiesAboutNumberOfChannels;
  565
+#ifdef OMAP_ENHANCEMENT
  566
+        quirks |= kSupportsMultipleFramesPerInputBuffer;
  567
+        quirks |= kDecoderCantRenderSmallClips;
  568
+#endif
395 569
     }
396 570
     if (!strcmp(componentName, "OMX.TI.AAC.decode")) {
397 571
         quirks |= kNeedsFlushBeforeDisable;
398 572
         quirks |= kRequiresFlushCompleteEmulation;
399 573
         quirks |= kSupportsMultipleFramesPerInputBuffer;
400 574
     }
  575
+#ifdef OMAP_ENHANCEMENT
  576
+    if (!strcmp(componentName, "OMX.TI.WMA.decode")) {
  577
+        quirks |= kNeedsFlushBeforeDisable;
  578
+        quirks |= kRequiresFlushCompleteEmulation;
  579
+    }
  580
+    if (!strcmp(componentName, "OMX.ITTIAM.WMA.decode")) {
  581
+       quirks |= kNeedsFlushBeforeDisable;
  582
+       quirks |= kRequiresFlushCompleteEmulation;
  583
+    }
  584
+    if (!strcmp(componentName, "OMX.ITTIAM.WMALSL.decode")) {
  585
+        quirks |= kNeedsFlushBeforeDisable;
  586
+        quirks |= kRequiresFlushCompleteEmulation;
  587
+    }
  588
+    if (!strcmp(componentName, "OMX.ITTIAM.WMAPRO.decode")) {
  589
+        quirks |= kNeedsFlushBeforeDisable;
  590
+        quirks |= kRequiresFlushCompleteEmulation;
  591
+    }
  592
+    if (!strcmp(componentName, "OMX.ITTIAM.AAC.decode")) {
  593
+
  594
+        quirks |= kNeedsFlushBeforeDisable;
  595
+        quirks |= kDecoderNeedsPortReconfiguration;
  596
+    }
  597
+    if (!strcmp(componentName, "OMX.PV.aacdec")) {
  598
+        quirks |= kNeedsFlushBeforeDisable;
  599
+        quirks |= kDecoderNeedsPortReconfiguration;
  600
+    }
  601
+#endif
401 602
     if (!strncmp(componentName, "OMX.qcom.video.encoder.", 23)) {
402 603
         quirks |= kRequiresLoadedToIdleAfterAllocation;
403 604
         quirks |= kRequiresAllocateBufferOnInputPorts;
... ...
@@ -427,24 +628,66 @@ uint32_t OMXCodec::getComponentQuirks(
427 628
         quirks |= kDefersOutputBufferAllocation;
428 629
         quirks |= kDoesNotRequireMemcpyOnOutputPort;
429 630
     }
  631
+#ifdef OMAP_ENHANCEMENT
  632
+    if (!strcmp(componentName, "OMX.TI.Video.Decoder") ||
  633
+            !strcmp(componentName, "OMX.TI.720P.Decoder")) {
  634
+        // TI Video Decoder and TI 720p Decoder must use buffers allocated
  635
+        // by Overlay for output port. So, I cannot call OMX_AllocateBuffer
  636
+        // on output port. I must use OMX_UseBuffer on input port to ensure
  637
+        // 128 byte alignment.
  638
+        quirks |= kRequiresAllocateBufferOnInputPorts;
  639
+        quirks |= kInputBufferSizesAreBogus;
  640
+
  641
+        if( flags & kPreferThumbnailMode) {
  642
+                quirks |= OMXCodec::kRequiresAllocateBufferOnOutputPorts;
  643
+        }
  644
+    }
  645
+#ifdef TARGET_OMAP4
  646
+    else if(!strcmp(componentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
  647
+        //quirks |= kRequiresAllocateBufferOnInputPorts;
430 648
 
  649
+        quirks |= kNeedsFlushBeforeDisable;
  650
+        if(flags & kPreferThumbnailMode)
  651
+        {
  652
+            quirks |= OMXCodec::kThumbnailMode;
  653
+        }
  654
+
  655
+        if(flags & kPreferInterlacedOutputContent) {
  656
+                quirks |= OMXCodec::kInterlacedOutputContent;
  657
+        }
  658
+
  659
+    }
  660
+#endif
  661
+    else if (!strncmp(componentName, "OMX.TI.", 7) || !strncmp("OMX.ITTIAM.", componentName, 11)) {
  662
+#else
431 663
     if (!strncmp(componentName, "OMX.TI.", 7)) {
  664
+#endif
432 665
         // Apparently I must not use OMX_UseBuffer on either input or
433 666
         // output ports on any of the TI components or quote:
434 667
         // "(I) may have unexpected problem (sic) which can be timing related
435 668
         //  and hard to reproduce."
436 669
 
  670
+#if defined(OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  671
+        if (!strncmp(componentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E", strlen("OMX.TI.DUCATI1.VIDEO.MPEG4E")) ||
  672
+           !strncmp(componentName, "OMX.TI.DUCATI1.VIDEO.H264E", strlen("OMX.TI.DUCATI1.VIDEO.H264E"))) {
  673
+            LOGV("USING DUCATI ENCODER. isEncoder : %d",isEncoder);
  674
+            quirks |= kRequiresAllocateBufferOnOutputPorts;
  675
+            quirks |= kAvoidMemcopyInputRecordingFrames;
  676
+        }
  677
+#else
437 678
         quirks |= kRequiresAllocateBufferOnInputPorts;
438 679
         quirks |= kRequiresAllocateBufferOnOutputPorts;
439  
-        if (!strncmp(componentName, "OMX.TI.Video.encoder", 20)) {
  680
+        if (!strncmp(componentName, "OMX.TI.Video.encoder", 20) ||
  681
+            !strncmp(componentName, "OMX.TI.720P.Encoder", 19)) {
440 682
             quirks |= kAvoidMemcopyInputRecordingFrames;
441 683
         }
  684
+#endif
442 685
     }
443  
-
  686
+#ifndef OMAP_ENHANCEMENT
444 687
     if (!strcmp(componentName, "OMX.TI.Video.Decoder")) {
445 688
         quirks |= kInputBufferSizesAreBogus;
446 689
     }
447  
-
  690
+#endif
448 691
     if (!strncmp(componentName, "OMX.SEC.", 8) && !isEncoder) {
449 692
         // These output buffers contain no video data, just some
450 693
         // opaque information that allows the overlay to display their
... ...
@@ -497,6 +740,15 @@ void OMXCodec::findMatchingCodecs(
497 740
         matchingCodecs->push(String8(componentName));
498 741
     }
499 742
 
  743
+#ifdef OMAP_ENHANCEMENT
  744
+    char value[PROPERTY_VALUE_MAX];
  745
+    property_get("debug.video.preferswcodec", value, "0");
  746
+    if (atoi(value))
  747
+    {
  748
+        flags |= kPreferSoftwareCodecs;
  749
+    }
  750
+#endif
  751
+
500 752
     if (flags & kPreferSoftwareCodecs) {
501 753
         matchingCodecs->sort(CompareSoftwareCodecsFirst);
502 754
     }
... ...
@@ -539,9 +791,11 @@ sp<MediaSource> OMXCodec::Create(
539 791
         }
540 792
 
541 793
         LOGV("Attempting to allocate OMX node '%s'", componentName);
542  
-
  794
+#ifdef OMAP_ENHANCEMENT
  795
+uint32_t quirks = getComponentQuirks(componentName, createEncoder, flags);
  796
+#else
543 797
         uint32_t quirks = getComponentQuirks(componentName, createEncoder);
544  
-
  798
+#endif
545 799
         if (!createEncoder
546 800
                 && (quirks & kOutputBuffersAreUnreadable)
547 801
                 && (flags & kClientNeedsFramebuffer)) {
... ...
@@ -581,13 +835,135 @@ sp<MediaSource> OMXCodec::Create(
581 835
     return NULL;
582 836
 }
583 837
 
  838
+#ifdef OMAP_ENHANCEMENT
  839
+// static
  840
+sp<MediaSource> OMXCodec::Create(
  841
+        const sp<IOMX> &omx,
  842
+        const sp<MetaData> &meta, bool createEncoder,
  843
+        const sp<MediaSource> &source,
  844
+        IOMX::node_id &nodeId,
  845
+        const char *matchComponentName,
  846
+        uint32_t flags) {
  847
+    const char *mime;
  848
+    bool success = meta->findCString(kKeyMIMEType, &mime);
  849
+    CHECK(success);
  850
+
  851
+    Vector<String8> matchingCodecs;
  852
+    findMatchingCodecs(
  853
+            mime, createEncoder, matchComponentName, flags, &matchingCodecs);
  854
+
  855
+    if (matchingCodecs.isEmpty()) {
  856
+        return NULL;
  857
+    }
  858
+
  859
+    sp<OMXCodecObserver> observer = new OMXCodecObserver;
  860
+    IOMX::node_id node = 0;
  861
+
  862
+    const char *componentName;
  863
+    for (size_t i = 0; i < matchingCodecs.size(); ++i) {
  864
+        componentName = matchingCodecs[i].string();
  865
+
  866
+#if BUILD_WITH_FULL_STAGEFRIGHT
  867
+        sp<MediaSource> softwareCodec =
  868
+            InstantiateSoftwareCodec(componentName, source);
  869
+
  870
+        if (softwareCodec != NULL) {
  871
+            LOGV("Successfully allocated software codec '%s'", componentName);
  872
+
  873
+            return softwareCodec;
  874
+        }
  875
+#endif
  876
+
  877
+        LOGV("Attempting to allocate OMX node '%s'", componentName);
  878
+
  879
+        status_t err = omx->allocateNode(componentName, observer, &node);
  880
+        if (err == OK) {
  881
+            LOGV("Successfully allocated OMX node '%s'", componentName);
  882
+
  883
+#ifdef TARGET_OMAP4
  884
+            sp<OMXCodec> codec = new OMXCodec(
  885
+                    omx, node, getComponentQuirks(componentName,createEncoder,flags),
  886
+                    createEncoder, mime, componentName,
  887
+                    source);
  888
+#else
  889
+            sp<OMXCodec> codec = new OMXCodec(
  890
+                    omx, node, getComponentQuirks(componentName,createEncoder),
  891
+                    createEncoder, mime, componentName,
  892
+                    source);
  893
+#endif
  894
+
  895
+            observer->setCodec(codec);
  896
+
  897
+            nodeId = node;
  898
+
  899
+            err = codec->configureCodec(meta,flags);
  900
+
  901
+            if (err == OK) {
  902
+                return codec;
  903
+            }
  904
+
  905
+            LOGV("Failed to configure codec '%s'", componentName);
  906
+        }
  907
+    }
  908
+
  909
+    return NULL;
  910
+}
  911
+#endif
  912
+
584 913
 status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
  914
+#if !(defined(OMAP_ENHANCEMENT) && defined (TARGET_OMAP4))
585 915
     if (!(flags & kIgnoreCodecSpecificData)) {
  916
+#endif
586 917
         uint32_t type;
587 918
         const void *data;
588 919
         size_t size;
589 920
 
590  
-        if (meta->findData(kKeyESDS, &type, &data, &size)) {
  921
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  922
+    status_t err;
  923
+
  924
+    if (meta->findData(kKeyStreamSpecificData, &type, &data, &size))
  925
+    {
  926
+        if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
  927
+
  928
+            if ((!strcasecmp(MEDIA_MIMETYPE_VIDEO_VP6, mMIME)) ||
  929
+                (!strcasecmp(MEDIA_MIMETYPE_VIDEO_VP7, mMIME))) {
  930
+
  931
+                LOGD("Setting VP6/7 Params");
  932
+                OMX_TI_PARAM_IVFFLAG tVP6Param;
  933
+                InitOMXParams(&tVP6Param);
  934
+                err = mOMX->getParameter(
  935
+                        mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoIvfMode, &tVP6Param, sizeof(tVP6Param));
  936
+
  937
+                CHECK_EQ(err, OK);
  938
+                tVP6Param.bIvfFlag = OMX_FALSE;
  939
+
  940
+                char *t = ((char *)(data));
  941
+                if ((t[0] == 'D') && (t[1] == 'K') && (t[2] == 'I') && (t[3] == 'F')){
  942
+                    LOGD("IVF Header Present. Size = %d. Limiting it to 32 as per spec.", size);
  943
+                    size = 32;
  944
+                    addCodecSpecificData(data, size);
  945
+                    tVP6Param.bIvfFlag = OMX_TRUE;
  946
+                }
  947
+                err = mOMX->setParameter(
  948
+                        mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoIvfMode, &tVP6Param, sizeof(tVP6Param));
  949
+
  950
+                OMX_TI_PARAM_PAYLOADHEADERFLAG tVP6Payloadheader;
  951
+                InitOMXParams(&tVP6Payloadheader);
  952
+                err = mOMX->getParameter(
  953
+                        mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoPayloadHeaderFlag, &tVP6Payloadheader, sizeof(tVP6Payloadheader));
  954
+                CHECK_EQ(err, OK);
  955
+                tVP6Payloadheader.bPayloadHeaderFlag = OMX_FALSE;
  956
+                err = mOMX->setParameter(
  957
+                        mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoPayloadHeaderFlag, &tVP6Payloadheader, sizeof(tVP6Payloadheader));
  958
+
  959
+            }
  960
+        }
  961
+        else addCodecSpecificData(data, size);
  962
+    }
  963
+    else if (meta->findData(kKeyESDS, &type, &data, &size)) {
  964
+#else
  965
+    if (meta->findData(kKeyESDS, &type, &data, &size)) {
  966
+#endif
591 967
             ESDS esds((const char *)data, size);
592 968
             CHECK_EQ(esds.InitCheck(), OK);
593 969
 
... ...
@@ -671,12 +1047,97 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
671 1047
                 LOGE("Profile and/or level exceed the decoder's capabilities.");
672 1048
                 return ERROR_UNSUPPORTED;
673 1049
             }
  1050
+#ifdef OMAP_ENHANCEMENT
  1051
+            int32_t width, height;
  1052
+            bool success = meta->findInt32(kKeyWidth, &width);
  1053
+            success = success && meta->findInt32(kKeyHeight, &height);
  1054
+            CHECK(success);
  1055
+            if (!strcmp(mComponentName, "OMX.TI.720P.Decoder")
  1056
+                && (profile == kAVCProfileBaseline && level <= 39)
  1057
+                && (width*height <= MAX_RESOLUTION)
  1058
+                && (width <= MAX_RESOLUTION_WIDTH && height <= MAX_RESOLUTION_HEIGHT ))
  1059
+            {
  1060
+                // Though this decoder can handle this profile/level,
  1061
+                // we prefer to use "OMX.TI.Video.Decoder" for
  1062
+                // Baseline Profile with level <=39 and sub 720p
  1063
+                return ERROR_UNSUPPORTED;
  1064
+            }
  1065
+#endif
674 1066
         }
  1067
+#ifdef OMAP_ENHANCEMENT
  1068
+    else if (meta->findData(kKeyHdr, &type, &data, &size)) {
  1069
+        CODEC_LOGV("Codec specific information of size %d", size);
  1070
+        addCodecSpecificData(data, size);
675 1071
     }
676 1072
 
  1073
+    if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_WMV, mMIME)) {
  1074
+        bool success = meta->findData(kKeyHdr, &type, &data, &size);
  1075
+        const uint8_t *ptr = (const uint8_t *)data;
  1076
+        CHECK(success);
  1077
+
  1078
+        OMX_U32 width = (((OMX_U32)ptr[18] << 24) | ((OMX_U32)ptr[17] << 16)
  1079
+                           | ((OMX_U32)ptr[16] << 8) | (OMX_U32)ptr[15]);
  1080
+        OMX_U32 height = (((OMX_U32)ptr[22] << 24) | ((OMX_U32)ptr[21] << 16)
  1081
+                           | ((OMX_U32)ptr[20] << 8) | (OMX_U32)ptr[19]);
  1082
+
  1083
+        CODEC_LOGV("Height and width = %u %u\n", height, width);
  1084
+
  1085
+        // MAX_RESOLUTION is used to take the decision between TI and Ittiam WMV codec.
  1086
+        if (!strcmp(mComponentName, "OMX.TI.Video.Decoder") &&
  1087
+            (width*height > MAX_RESOLUTION)) {
  1088
+
  1089
+            // need OMX.TI.720P.Decoder
  1090
+            return ERROR_UNSUPPORTED;
  1091
+        }
  1092
+        if(!strcmp(mComponentName, "OMX.TI.720P.Decoder")) {
  1093
+            OMX_U32 NewCompression = MAKEFOURCC_WMC((OMX_U8)ptr[27], (OMX_U8)ptr[28],
  1094
+                                                    (OMX_U8)ptr[29], (OMX_U8)ptr[30]);
  1095
+            OMX_U32 StreamType;
  1096
+            OMX_PARAM_WMVFILETYPE WMVFileType;
  1097
+            InitOMXParams(&WMVFileType);
  1098
+
  1099
+            if (NewCompression == FOURCC_WMV3) {
  1100
+                CODEC_LOGV("VIDDEC_WMV_RCVSTREAM\n");
  1101
+                StreamType = VIDDEC_WMV_RCVSTREAM;
  1102
+            } else if (NewCompression == FOURCC_WVC1) {
  1103
+                CODEC_LOGV("VIDDEC_WMV_ELEMSTREAM\n");
  1104
+                StreamType = VIDDEC_WMV_ELEMSTREAM;
  1105
+            } else {
  1106
+                CODEC_LOGI("ERROR...  PROFILE NOT KNOWN ASSUMED TO BE VIDDEC_WMV_RCVSTREAM\n");
  1107
+                StreamType = VIDDEC_WMV_RCVSTREAM;
  1108
+            }
  1109
+            WMVFileType.nWmvFileType = StreamType;
  1110
+
  1111
+            status_t err = mOMX->setParameter(mNode,
  1112
+                                              (OMX_INDEXTYPE)VideoDecodeCustomParamWMVFileType,
  1113
+                                              &WMVFileType, sizeof(WMVFileType));
  1114
+            if (err != OMX_ErrorNone) {
  1115
+                return err;
  1116
+            }
  1117
+        }
  1118
+    }
  1119
+#endif
  1120
+
  1121
+#if !(defined(OMAP_ENHANCEMENT) && defined (TARGET_OMAP4))
  1122
+    }
  1123
+#endif
  1124
+
677 1125
     int32_t bitRate = 0;
678 1126
     if (mIsEncoder) {
679 1127
         CHECK(meta->findInt32(kKeyBitRate, &bitRate));
  1128
+
  1129
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP3)
  1130
+        if (!strcmp(mComponentName, "OMX.TI.Video.encoder")) {
  1131
+            int32_t width, height;
  1132
+            bool success = meta->findInt32(kKeyWidth, &width);
  1133
+            success = success && meta->findInt32(kKeyHeight, &height);
  1134
+            CHECK(success);
  1135
+            if (width*height > MAX_RESOLUTION) {
  1136
+                // need OMX.TI.720P.Encoder
  1137
+                return ERROR_UNSUPPORTED;
  1138
+            }
  1139
+        }
  1140
+#endif
680 1141
     }
681 1142
     if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_NB, mMIME)) {
682 1143
         setAMRFormat(false /* isWAMR */, bitRate);
... ...
@@ -692,6 +1153,28 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
692 1153
 #ifndef DONT_SET_AUDIO_AAC_FORMAT
693 1154
         setAACFormat(numChannels, sampleRate, bitRate);
694 1155
 #endif
  1156
+#ifdef OMAP_ENHANCEMENT
  1157
+        // Configure TI OMX component to FrameMode for AAC-ADTS
  1158
+        if (!strcmp(mComponentName, "OMX.TI.AAC.decode")) {
  1159
+            OMX_INDEXTYPE index;
  1160
+
  1161
+            CODEC_LOGV("OMXCodec::configureCodec() TI AAC - Configure Component to FrameMode");
  1162
+
  1163
+            // Get Extension Index from Component
  1164
+            status_t err = mOMX->getExtensionIndex(mNode, "OMX.TI.index.config.AacDecFrameModeInfo", &index);
  1165
+            if (err != OK) {
  1166
+                CODEC_LOGV("OMXCodec::configureCodec() TI AAC - Problem getting ExtensionIndex - Use SteamMode");
  1167
+            }
  1168
+            else {
  1169
+                OMX_U16 framemode = 1;
  1170
+                // Set FrameMode for ADTS streams
  1171
+                err = mOMX->setConfig(mNode, index, &framemode, sizeof(framemode));
  1172
+                if (err != OK) {
  1173
+                    CODEC_LOGV("OMXCodec::configureCodec() TI AAC - Problem configuring FrameMode - Use SteamMode");
  1174
+                }
  1175
+            }
  1176
+        }
  1177
+#endif
695 1178
     }
696 1179
 
697 1180
     if (!strncasecmp(mMIME, "video/", 6)) {
... ...
@@ -703,6 +1186,142 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
703 1186
             bool success = meta->findInt32(kKeyWidth, &width);
704 1187
             success = success && meta->findInt32(kKeyHeight, &height);
705 1188
             CHECK(success);
  1189
+
  1190
+#ifdef OMAP_ENHANCEMENT
  1191
+
  1192
+            /* Update proper Profile, Level, No. of Reference frames.
  1193
+               This will aid in less (tiler) memory utilization by ducati side */
  1194
+            if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
  1195
+                /* save video FPS */
  1196
+                if (!(meta->findInt32(kKeyVideoFPS, &mVideoFPS))) {
  1197
+                    mVideoFPS = 30; //default value in case of FPS data not found
  1198
+                }
  1199
+
  1200
+                int32_t vprofile,vlevel,vinterlaced,vnumrefframes;
  1201
+
  1202
+                if ((!strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mMIME)) &&
  1203
+                        meta->findInt32(kKeyVideoProfile, &vprofile) &&
  1204
+                        meta->findInt32(kKeyVideoLevel, &vlevel) &&
  1205
+                        meta->findInt32(kKeyVideoInterlaced, &vinterlaced) &&
  1206
+                        meta->findInt32(kKeyNumRefFrames, &vnumrefframes))
  1207
+                {
  1208
+
  1209
+                    OMX_VIDEO_PARAM_AVCTYPE h264type;
  1210
+                    InitOMXParams(&h264type);
  1211
+                    h264type.nPortIndex = kPortIndexInput;
  1212
+
  1213
+                    status_t err = mOMX->getParameter(
  1214
+                            mNode, OMX_IndexParamVideoAvc, &h264type, sizeof(h264type));
  1215
+                    CHECK_EQ(err, OK);
  1216
+
  1217
+                    //h264type.nBFrames = 0; //check if requred
  1218
+
  1219
+
  1220
+                    /* Update profile from uint32_t type */
  1221
+                    switch(vprofile)
  1222
+                    {
  1223
+                        case kAVCProfileBaseline :
  1224
+                                    h264type.eProfile = OMX_VIDEO_AVCProfileBaseline;
  1225
+                                    break;
  1226
+                        case kAVCProfileMain :
  1227
+                                    h264type.eProfile = OMX_VIDEO_AVCProfileMain;
  1228
+                                    break;
  1229
+                        case kAVCProfileExtended :
  1230
+                                    h264type.eProfile = OMX_VIDEO_AVCProfileExtended;
  1231
+                                    break;
  1232
+                        case kAVCProfileHigh :
  1233
+                                    h264type.eProfile = OMX_VIDEO_AVCProfileHigh;
  1234
+                                    break;
  1235
+
  1236
+                        case kAVCProfileHigh10 :
  1237
+                        case kAVCProfileHigh422 :
  1238
+                        case kAVCProfileHigh444 :
  1239
+                        default:
  1240
+                                    //Unsupported profiles by OMX.TI.DUCATI1.VIDEO.DECODER
  1241
+                                    LOGE("profile code 0x%x %d not supported", vprofile,vprofile);
  1242
+                                    CHECK_EQ(0,1);
  1243
+                                    return UNKNOWN_ERROR;
  1244
+                    }
  1245
+
  1246
+
  1247
+                    switch(vlevel)
  1248
+                    {
  1249
+
  1250
+                        case 9 :
  1251
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel1b;
  1252
+                                    break;
  1253
+                        case 10 :
  1254
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel1;
  1255
+                                    break;
  1256
+                        case 11 :
  1257
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel11;
  1258
+                                    break;
  1259
+                        case 12 :
  1260
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel12;
  1261
+                                    break;
  1262
+                        case 13 :
  1263
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel13;
  1264
+                                    break;
  1265
+                        case 20 :
  1266
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel2;
  1267
+                                    break;
  1268
+                        case 21 :
  1269
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel21;
  1270
+                                    break;
  1271
+                        case 22 :
  1272
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel22;
  1273
+                                    break;
  1274
+                        case 30 :
  1275
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel3;
  1276
+                                    break;
  1277
+                        case 31 :
  1278
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel31;
  1279
+                                    break;
  1280
+                        case 32 :
  1281
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel32;
  1282
+                                    break;
  1283
+
  1284
+                        case 40 :
  1285
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel4;
  1286
+                                    break;
  1287
+
  1288
+                        case 41 :
  1289
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel41;
  1290
+                                    break;
  1291
+
  1292
+                        case 42 :
  1293
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel42;
  1294
+                                    break;
  1295
+
  1296
+                        case 50 :
  1297
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel5;
  1298
+                                    break;
  1299
+
  1300
+                        case 51 :
  1301
+                                    h264type.eLevel = OMX_VIDEO_AVCLevel51;
  1302
+                                    break;
  1303
+
  1304
+                        default:
  1305
+                                    //Unsupported level value
  1306
+                                    LOGE("profile code 0x%x %d not supported", vlevel,vlevel);
  1307
+                                    CHECK_EQ(0,1);
  1308
+                                    return UNKNOWN_ERROR;
  1309
+                    }
  1310
+
  1311
+                    h264type.nRefFrames = vnumrefframes;
  1312
+
  1313
+                    err = mOMX->setParameter(
  1314
+                            mNode, OMX_IndexParamVideoAvc, &h264type, sizeof(h264type));
  1315
+                    CHECK_EQ(err, OK);
  1316
+
  1317
+                    /* Cross check from component */
  1318
+                    err = mOMX->getParameter(
  1319
+                            mNode, OMX_IndexParamVideoAvc, &h264type, sizeof(h264type));
  1320
+
  1321
+                    LOGD("Updated. H264 Component profile %d level %d NRefFrames %d", h264type.eProfile,h264type.eLevel, (int)h264type.nRefFrames);
  1322
+                }
  1323
+            }
  1324
+#endif
706 1325
             status_t err = setVideoOutputFormat(
707 1326
                     mMIME, width, height);
708 1327
 
... ...
@@ -737,6 +1356,14 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
737 1356
 
738 1357
     int32_t maxInputSize;
739 1358
     if (meta->findInt32(kKeyMaxInputSize, &maxInputSize)) {
  1359
+#ifdef OMAP_ENHANCEMENT
  1360
+        if (!strcmp(mComponentName, "OMX.TI.Video.Decoder") || !strcmp(mComponentName, "OMX.TI.720P.Decoder")) {
  1361
+            // We need to allocate at least twice the "maxInputSize"
  1362
+            // to get enough room for internal OMX buffer handling.
  1363
+            maxInputSize += maxInputSize;
  1364
+            CODEC_LOGV("Resize maxInputSize*2, maxInputSize=%d", maxInputSize);
  1365
+        }
  1366
+#endif
740 1367
         setMinBufferSize(kPortIndexInput, (OMX_U32)maxInputSize);
741 1368
     }
742 1369
 
... ...
@@ -775,6 +1402,17 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta, uint32_t flags) {
775 1402
         mQuirks &= ~kOutputBuffersAreUnreadable;
776 1403
     }
777 1404
 
  1405
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1406
+    mNSecsToWait = 5000000000; // 5 seconds
  1407
+    const char *flash_fp_usecase;
  1408
+    const char *flash_em_usecase;
  1409
+    if ((meta->findCString('fpfl', &flash_fp_usecase)) ||
  1410
+        (meta->findCString('fpem', &flash_em_usecase))) {
  1411
+        LOGD("\n\n\n Executing a flash usecase \n\n\n");
  1412
+        mNSecsToWait = 0;
  1413
+    }
  1414
+#endif
  1415
+
778 1416
     return OK;
779 1417
 }
780 1418
 
... ...
@@ -792,6 +1430,17 @@ void OMXCodec::setMinBufferSize(OMX_U32 portIndex, OMX_U32 size) {
792 1430
         def.nBufferSize = size;
793 1431
     }
794 1432
 
  1433
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1434
+    /* Aligning the buffer size as observed memory failures in allocateBuffersOnPort
  1435
+     * for input port incase buffer sizes are not Cache line boundary aligned.
  1436
+     * Actually the Memory Dealer allocates a large chunk for the Total buffer size.
  1437
+     * While requesting individual buffers, it provides chunks (offset) from the large
  1438
+     * memory. During this, it provides address based on Cache line boundary. Hence
  1439
+     * there would not be sufficient memory for the last chunk and it fails */
  1440
+    def.nBufferSize = ((def.nBufferSize + CACHELINE_BOUNDARY_MEMALIGNMENT - 1) &
  1441
+                        ~(CACHELINE_BOUNDARY_MEMALIGNMENT - 1));
  1442
+#endif
  1443
+
795 1444
     err = mOMX->setParameter(
796 1445
             mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
797 1446
     CHECK_EQ(err, OK);
... ...
@@ -839,7 +1488,8 @@ status_t OMXCodec::setVideoPortFormatType(
839 1488
              index, format.eCompressionFormat, format.eColorFormat);
840 1489
 #endif
841 1490
 
842  
-        if (!strcmp("OMX.TI.Video.encoder", mComponentName)) {
  1491
+        if (!strcmp("OMX.TI.Video.encoder", mComponentName) ||
  1492
+            !strcmp("OMX.TI.720P.Encoder", mComponentName)) {
843 1493
             if (portIndex == kPortIndexInput
844 1494
                     && colorFormat == format.eColorFormat) {
845 1495
                 // eCompressionFormat does not seem right.
... ...
@@ -854,6 +1504,20 @@ status_t OMXCodec::setVideoPortFormatType(
854 1504
             }
855 1505
         }
856 1506
 
  1507
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  1508
+        if (!strcmp("OMX.TI.DUCATI1.VIDEO.DECODER", mComponentName)) {
  1509
+            if ( (compressionFormat == OMX_VIDEO_CodingH263) &&
  1510
+                 (format.eCompressionFormat != compressionFormat) ) {
  1511
+                // Ducati Decoder returns MPEG4 as default compression type.
  1512
+                // Update H263 compression type
  1513
+                format.eCompressionFormat=compressionFormat;
  1514
+                found = true;
  1515
+                break;
  1516
+            }
  1517
+        format.eColorFormat = colorFormat; //HACK. Should be removed in 1.20 ducati release
  1518
+        }
  1519
+#endif
  1520
+
857 1521
         if (format.eCompressionFormat == compressionFormat
858 1522
             && format.eColorFormat == colorFormat) {
859 1523
             found = true;
... ...
@@ -886,6 +1550,11 @@ static size_t getFrameSize(
886 1550
         case OMX_COLOR_FormatYUV420SemiPlanar:
887 1551
             return (width * height * 3) / 2;
888 1552
 
  1553
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1554
+        case OMX_COLOR_FormatYUV420PackedSemiPlanar:
  1555
+            return (4096 * height *3)/2;
  1556
+#endif
  1557
+
889 1558
         default:
890 1559
             CHECK(!"Should not be here. Unsupported color format.");
891 1560
             break;
... ...
@@ -902,7 +1571,8 @@ status_t OMXCodec::findTargetColorFormat(
902 1571
     if (meta->findInt32(kKeyColorFormat, &targetColorFormat)) {
903 1572
         *colorFormat = (OMX_COLOR_FORMATTYPE) targetColorFormat;
904 1573
     } else {
905  
-        if (!strcasecmp("OMX.TI.Video.encoder", mComponentName)) {
  1574
+        if (!strcasecmp("OMX.TI.Video.encoder", mComponentName) ||
  1575
+            !strcasecmp("OMX.TI.720P.Encoder", mComponentName)) {
906 1576
             *colorFormat = OMX_COLOR_FormatYCbYCr;
907 1577
         }
908 1578
     }
... ...
@@ -956,12 +1626,20 @@ void OMXCodec::setVideoInputFormat(
956 1626
         const char *mime, const sp<MetaData>& meta) {
957 1627
 
958 1628
     int32_t width, height, frameRate, bitRate, stride, sliceHeight;
  1629
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1630
+    int32_t paddedWidth, paddedHeight;
  1631
+#endif
959 1632
     bool success = meta->findInt32(kKeyWidth, &width);
960 1633
     success = success && meta->findInt32(kKeyHeight, &height);
961 1634
     success = success && meta->findInt32(kKeySampleRate, &frameRate);
962 1635
     success = success && meta->findInt32(kKeyBitRate, &bitRate);
963 1636
     success = success && meta->findInt32(kKeyStride, &stride);
964 1637
     success = success && meta->findInt32(kKeySliceHeight, &sliceHeight);
  1638
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1639
+    success = success && meta->findInt32(kKeyPaddedWidth, &paddedWidth);
  1640
+    success = success && meta->findInt32(kKeyPaddedHeight, &paddedHeight);
  1641
+#endif
  1642
+
965 1643
     CHECK(success);
966 1644
     CHECK(stride != 0);
967 1645
 
... ...
@@ -972,6 +1650,12 @@ void OMXCodec::setVideoInputFormat(
972 1650
         compressionFormat = OMX_VIDEO_CodingMPEG4;
973 1651
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_H263, mime)) {
974 1652
         compressionFormat = OMX_VIDEO_CodingH263;
  1653
+#ifdef OMAP_ENHANCEMENT
  1654
+    }
  1655
+    else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_WMV, mime))
  1656
+    {
  1657
+        compressionFormat = OMX_VIDEO_CodingWMV;
  1658
+#endif
975 1659
     } else {
976 1660
         LOGE("Not a supported video mime type: %s", mime);
977 1661
         CHECK(!"Should not be here. Not a supported video mime type.");
... ...
@@ -996,15 +1680,37 @@ void OMXCodec::setVideoInputFormat(
996 1680
             mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
997 1681
     CHECK_EQ(err, OK);
998 1682
 
  1683
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1684
+    def.nBufferSize = getFrameSize(colorFormat,
  1685
+            stride > 0? stride: -stride, paddedHeight);
  1686
+#else
999 1687
     def.nBufferSize = getFrameSize(colorFormat,
1000 1688
             stride > 0? stride: -stride, sliceHeight);
  1689
+#endif
1001 1690
 
1002 1691
     CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
1003 1692
 
1004 1693
     video_def->nFrameWidth = width;
1005 1694
     video_def->nFrameHeight = height;
1006 1695
     video_def->nStride = stride;
  1696
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1697
+    if( !strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E")
  1698
+        || !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E")){
  1699
+        video_def->nStride = 4096; // TI 2D-Buffer specific Hardcoding
  1700
+    }
  1701
+
  1702
+    def.nBufferCountActual = INPUT_BUFFER_COUNT;
  1703
+    if(!strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E"))
  1704
+    {
  1705
+#ifdef SUPPORT_B_FRAMES
  1706
+        def.nBufferCountActual = OMX_NUM_B_FRAMES + 1;;
  1707
+#else
  1708
+        def.nBufferCountActual = 2;
  1709
+#endif
  1710
+    }
  1711
+#else
1007 1712
     video_def->nSliceHeight = sliceHeight;
  1713
+#endif
1008 1714
     video_def->xFramerate = (frameRate << 16);  // Q16 format
1009 1715
     video_def->eCompressionFormat = OMX_VIDEO_CodingUnused;
1010 1716
     video_def->eColorFormat = colorFormat;
... ...
@@ -1037,10 +1743,40 @@ void OMXCodec::setVideoInputFormat(
1037 1743
         def.nBufferSize = ((def.nBufferSize * 3) >> 1);
1038 1744
     }
1039 1745
 
  1746
+#ifdef TARGET_OMAP4
  1747
+    def.nBufferCountActual = OUTPUT_BUFFER_COUNT;
  1748
+#endif
1040 1749
     err = mOMX->setParameter(
1041 1750
             mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
1042 1751
     CHECK_EQ(err, OK);
1043 1752
 
  1753
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1754
+    if( !strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E")
  1755
+        || !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E")){
  1756
+
  1757
+        //OMX_TI_IndexParam2DBufferAllocDimension
  1758
+        OMX_CONFIG_RECTTYPE tFrameDim;
  1759
+        tFrameDim.nPortIndex = kPortIndexInput;
  1760
+        tFrameDim.nWidth = paddedWidth;
  1761
+        tFrameDim.nHeight = paddedHeight;
  1762
+        InitOMXParams(&tFrameDim);
  1763
+
  1764
+        err = mOMX->setParameter( mNode, (OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, &tFrameDim, sizeof(tFrameDim));
  1765
+            CHECK_EQ(err, OK);
  1766
+
  1767
+        //OMX_TI_IndexParamBufferPreAnnouncement
  1768
+        OMX_TI_PARAM_BUFFERPREANNOUNCE PreAnnouncement;
  1769
+        InitOMXParams(&PreAnnouncement);
  1770
+        PreAnnouncement.nPortIndex = kPortIndexInput;
  1771
+        err = mOMX->getParameter( mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamBufferPreAnnouncement, &PreAnnouncement, sizeof(PreAnnouncement));
  1772
+        CHECK_EQ(err, OK);
  1773
+
  1774
+        PreAnnouncement.bEnabled = OMX_FALSE;
  1775
+        err = mOMX->setParameter( mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamBufferPreAnnouncement, &PreAnnouncement,sizeof(PreAnnouncement));
  1776
+        CHECK_EQ(err, OK);
  1777
+    }
  1778
+#endif
  1779
+
1044 1780
     /////////////////// Codec-specific ////////////////////////
1045 1781
     switch (compressionFormat) {
1046 1782
         case OMX_VIDEO_CodingMPEG4:
... ...
@@ -1090,8 +1826,13 @@ status_t OMXCodec::setupErrorCorrectionParameters() {
1090 1826
     }
1091 1827
 
1092 1828
     errorCorrectionType.bEnableHEC = OMX_FALSE;
  1829
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  1830
+    errorCorrectionType.bEnableResync = OMX_FALSE;
  1831
+    errorCorrectionType.nResynchMarkerSpacing = 0;
  1832
+#else
1093 1833
     errorCorrectionType.bEnableResync = OMX_TRUE;
1094 1834
     errorCorrectionType.nResynchMarkerSpacing = 256;
  1835
+#endif
1095 1836
     errorCorrectionType.bEnableDataPartitioning = OMX_FALSE;
1096 1837
     errorCorrectionType.bEnableRVLC = OMX_FALSE;
1097 1838
 
... ...
@@ -1116,7 +1857,19 @@ status_t OMXCodec::setupBitRate(int32_t bitRate) {
1116 1857
             &bitrateType, sizeof(bitrateType));
1117 1858
     CHECK_EQ(err, OK);
1118 1859
 
  1860
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  1861
+    if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.H264E"))
  1862
+    {
  1863
+        bitrateType.eControlRate = OMX_Video_ControlRateVariable;
  1864
+    }
  1865
+    else if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E"))
  1866
+    {
  1867
+        bitrateType.eControlRate = OMX_Video_ControlRateVariable;
  1868
+    }
  1869
+#else
1119 1870
     bitrateType.eControlRate = OMX_Video_ControlRateVariable;
  1871
+#endif
  1872
+
1120 1873
     bitrateType.nTargetBitrate = bitRate;
1121 1874
 
1122 1875
     err = mOMX->setParameter(
... ...
@@ -1126,6 +1879,120 @@ status_t OMXCodec::setupBitRate(int32_t bitRate) {
1126 1879
     return OK;
1127 1880
 }
1128 1881
 
  1882
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  1883
+status_t OMXCodec::setupEncoderPresetParams(int32_t isS3DEnabled) {
  1884
+    OMX_VIDEO_PARAM_ENCODER_PRESETTYPE EncoderPreset;
  1885
+    status_t Err = OK;
  1886
+
  1887
+    /*Encoder Preset settings*/
  1888
+    InitOMXParams(&EncoderPreset);
  1889
+    EncoderPreset.nPortIndex = kPortIndexOutput;
  1890
+    Err = mOMX->getParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoEncoderPreset, &EncoderPreset,sizeof(EncoderPreset));
  1891
+    CHECK_EQ(Err, OK);
  1892
+
  1893
+    if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.H264E"))
  1894
+    {
  1895
+//#ifdef FOURMV_ENABLED
  1896
+        if(isS3DEnabled)
  1897
+            EncoderPreset.eEncodingModePreset = OMX_Video_Enc_User_Defined;
  1898
+        else
  1899
+            EncoderPreset.eEncodingModePreset = OMX_Video_Enc_Med_Speed_High_Quality;
  1900
+
  1901
+        EncoderPreset.eRateControlPreset= OMX_Video_RC_Storage ; //mpeg4VencClient->encoderPreset.eRateControlPreset;  // 4
  1902
+//#endif
  1903
+    }
  1904
+    else if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E"))
  1905
+    {
  1906
+        EncoderPreset.eEncodingModePreset = OMX_Video_Enc_User_Defined; // mpeg4VencClient->encoderPreset.eEncodingModePreset; // 2
  1907
+        EncoderPreset.eRateControlPreset= OMX_Video_RC_Storage ; //mpeg4VencClient->encoderPreset.eRateControlPreset;  // 4
  1908
+    }
  1909
+
  1910
+    Err = mOMX->setParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoEncoderPreset, &EncoderPreset,sizeof(EncoderPreset));
  1911
+    CHECK_EQ(Err, OK);
  1912
+
  1913
+    return Err;
  1914
+}
  1915
+#endif
  1916
+
  1917
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  1918
+
  1919
+static int32_t getFrameLayout(const char* frameLayout)
  1920
+{
  1921
+    if (!strcmp(frameLayout, TICameraParameters::S3D_TB_FULL)) {
  1922
+       return OMX_TI_Video_FRAMEPACK_TOP_BOTTOM;
  1923
+    }
  1924
+
  1925
+    if (!strcmp(frameLayout, TICameraParameters::S3D_SS_FULL)) {
  1926
+        return OMX_TI_Video_FRAMEPACK_SIDE_BY_SIDE;
  1927
+    }
  1928
+    if (!strcmp(frameLayout, TICameraParameters::S3D_TB_SUBSAMPLED)) {
  1929
+        return OMX_TI_Video_FRAMEPACK_TOP_BOTTOM;
  1930
+    }
  1931
+
  1932
+    if (!strcmp(frameLayout,TICameraParameters::S3D_SS_SUBSAMPLED)) {
  1933
+       return OMX_TI_Video_FRAMEPACK_SIDE_BY_SIDE;
  1934
+    }
  1935
+
  1936
+    LOGE("Unsupported frame layout (%s)", frameLayout);
  1937
+
  1938
+    CHECK_EQ(0, "Unsupported frame layout");
  1939
+    return OMX_TI_Video_FRAMEPACK_TOP_BOTTOM;
  1940
+}
  1941
+
  1942
+status_t OMXCodec::setupEncoderFrameDataContentParams(const sp<MetaData>& meta) {
  1943
+    OMX_TI_VIDEO_PARAM_FRAMEDATACONTENTTYPE FrameDataType;
  1944
+    status_t Err = OK;
  1945
+    int32_t seiEncodingType;
  1946
+    const char *frameLayout;
  1947
+
  1948
+    bool success = meta->findInt32(kKeySEIEncodingType, &seiEncodingType);
  1949
+    CHECK(success);
  1950
+
  1951
+    InitOMXParams(&FrameDataType);
  1952
+    FrameDataType.nPortIndex = kPortIndexInput;
  1953
+    Err = mOMX->getParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoFrameDataContentSettings, &FrameDataType,sizeof(FrameDataType));
  1954
+    CHECK_EQ(Err, OK);
  1955
+
  1956
+    FrameDataType.eContentType = (OMX_TI_VIDEO_FRAMECONTENTTYPE) seiEncodingType;
  1957
+    Err = mOMX->setParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamVideoFrameDataContentSettings, &FrameDataType,sizeof(FrameDataType));
  1958
+    CHECK_EQ(Err, OK);
  1959
+
  1960
+    if(OMX_TI_Video_AVC_2010_StereoFramePackingType == seiEncodingType) {
  1961
+        success = meta->findCString(kKeyFrameLayout, &frameLayout);
  1962
+        CHECK(success);
  1963
+
  1964
+        OMX_TI_VIDEO_PARAM_AVCENC_FRAMEPACKINGINFO2010 SettingsSEI2010;
  1965
+        InitOMXParams(&SettingsSEI2010);
  1966
+        SettingsSEI2010.nPortIndex = kPortIndexInput;
  1967
+        Err = mOMX->getParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamStereoFramePacking2010Settings, &SettingsSEI2010,sizeof(SettingsSEI2010));
  1968
+        CHECK_EQ(Err, OK);
  1969
+
  1970
+        SettingsSEI2010.eFramePackingType = (OMX_TI_VIDEO_AVCSTEREO_FRAMEPACKTYPE) getFrameLayout(frameLayout);
  1971
+        SettingsSEI2010.nFrame0PositionX = 0;
  1972
+        SettingsSEI2010.nFrame0PositionY = 0;
  1973
+        SettingsSEI2010.nFrame1PositionX = 0;
  1974
+        SettingsSEI2010.nFrame1PositionY = 0;
  1975
+        Err = mOMX->setParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamStereoFramePacking2010Settings, &SettingsSEI2010,sizeof(SettingsSEI2010));
  1976
+        CHECK_EQ(Err, OK);
  1977
+    }
  1978
+    else if(OMX_TI_Video_AVC_2004_StereoInfoType == seiEncodingType)
  1979
+    {
  1980
+        OMX_TI_VIDEO_PARAM_AVCENC_STEREOINFO2004 SettingsSEI2004;
  1981
+        InitOMXParams(&SettingsSEI2004);
  1982
+        SettingsSEI2004.nPortIndex = kPortIndexInput;
  1983
+        Err = mOMX->getParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamStereoInfo2004Settings, &SettingsSEI2004,sizeof(SettingsSEI2004));
  1984
+        CHECK_EQ(Err, OK);
  1985
+
  1986
+        SettingsSEI2004.btopFieldIsLeftViewFlag = OMX_TRUE;
  1987
+        SettingsSEI2004.bViewSelfContainedFlag = OMX_FALSE;
  1988
+        Err = mOMX->setParameter(mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamStereoInfo2004Settings, &SettingsSEI2004,sizeof(SettingsSEI2004));
  1989
+        CHECK_EQ(Err, OK);
  1990
+    }
  1991
+
  1992
+    return Err;
  1993
+}
  1994
+#endif
  1995
+
1129 1996
 status_t OMXCodec::getVideoProfileLevel(
1130 1997
         const sp<MetaData>& meta,
1131 1998
         const CodecProfileLevel& defaultProfileLevel,
... ...
@@ -1214,6 +2081,11 @@ status_t OMXCodec::setupH263EncoderParameters(const sp<MetaData>& meta) {
1214 2081
     h263type.nPictureHeaderRepetition = 0;
1215 2082
     h263type.nGOBHeaderInterval = 0;
1216 2083
 
  2084
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  2085
+    h263type.eProfile = OMX_VIDEO_H263ProfileBaseline;
  2086
+    h263type.eLevel =  OMX_VIDEO_H263Level70;
  2087
+#endif
  2088
+
1217 2089
     err = mOMX->setParameter(
1218 2090
             mNode, OMX_IndexParamVideoH263, &h263type, sizeof(h263type));
1219 2091
     if (!(mQuirks & kCanNotSetVideoParameters)) {
... ...
@@ -1222,6 +2094,45 @@ status_t OMXCodec::setupH263EncoderParameters(const sp<MetaData>& meta) {
1222 2094
 
1223 2095
     CHECK_EQ(setupBitRate(bitRate), OK);
1224 2096
     CHECK_EQ(setupErrorCorrectionParameters(), OK);
  2097
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  2098
+    CHECK_EQ(setupEncoderPresetParams(false), OK);
  2099
+
  2100
+     //OMX_VIDEO_PARAM_MOTIONVECTORTYPE Settings
  2101
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE MotionVector;
  2102
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE RefreshParam;
  2103
+    InitOMXParams(&MotionVector);
  2104
+    MotionVector.nPortIndex = kPortIndexOutput;
  2105
+
  2106
+    err = mOMX->getParameter(
  2107
+            mNode, OMX_IndexParamVideoMotionVector, &MotionVector,sizeof(MotionVector));
  2108
+
  2109
+    MotionVector.nPortIndex = kPortIndexOutput;
  2110
+
  2111
+    // extra parameters - hardcoded
  2112
+    MotionVector.sXSearchRange = 16;
  2113
+    MotionVector.sYSearchRange = 16;
  2114
+    MotionVector.bFourMV =  OMX_FALSE;
  2115
+    MotionVector.eAccuracy =  OMX_Video_MotionVectorHalfPel ;
  2116
+    MotionVector.bUnrestrictedMVs = OMX_TRUE;
  2117
+
  2118
+    err = mOMX->setParameter(
  2119
+            mNode, OMX_IndexParamVideoMotionVector, &MotionVector,sizeof(MotionVector));
  2120
+
  2121
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE Settings
  2122
+     InitOMXParams(&RefreshParam);
  2123
+    RefreshParam.nPortIndex = kPortIndexOutput;
  2124
+
  2125
+    err = mOMX->getParameter(
  2126
+            mNode, OMX_IndexParamVideoIntraRefresh, &RefreshParam,sizeof(RefreshParam));
  2127
+
  2128
+    // extra parameters - hardcoded based on PV defaults
  2129
+    RefreshParam.nPortIndex = kPortIndexOutput;
  2130
+    RefreshParam.eRefreshMode = OMX_VIDEO_IntraRefreshBoth;
  2131
+    //RefreshParam.nCirMBs = 0;
  2132
+
  2133
+    err = mOMX->setParameter(mNode, OMX_IndexParamVideoIntraRefresh, &RefreshParam,sizeof(RefreshParam));
  2134
+#endif
  2135
+
1225 2136
 
1226 2137
     return OK;
1227 2138
 }
... ...
@@ -1247,7 +2158,12 @@ status_t OMXCodec::setupMPEG4EncoderParameters(const sp<MetaData>& meta) {
1247 2158
     mpeg4type.nAllowedPictureTypes =
1248 2159
         OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
1249 2160
 
  2161
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  2162
+    mpeg4type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate) -1;
  2163
+#else
1250 2164
     mpeg4type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
  2165
+#endif
  2166
+
1251 2167
     if (mpeg4type.nPFrames == 0) {
1252 2168
         mpeg4type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI;
1253 2169
     }
... ...
@@ -1255,6 +2171,20 @@ status_t OMXCodec::setupMPEG4EncoderParameters(const sp<MetaData>& meta) {
1255 2171
     mpeg4type.nIDCVLCThreshold = 0;
1256 2172
     mpeg4type.bACPred = OMX_TRUE;
1257 2173
     mpeg4type.nMaxPacketSize = 256;
  2174
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  2175
+    int32_t width, height;
  2176
+    success = success && meta->findInt32(kKeyWidth, &width);
  2177
+    success = success && meta->findInt32(kKeyHeight, &height);
  2178
+    // In order to have normal amount of resync markers(and packets) in the encoded stream,
  2179
+    // we need set this value to 4096, this will reduce the number of bits used for marking
  2180
+    // seperate packets in the stream and allow us to use these bits for other purposes.
  2181
+    if((width >= 640) || (height >= 480)) {
  2182
+    // To improve performance
  2183
+        if( (frameRate > 15) && (bitRate > 2000000)) {
  2184
+            mpeg4type.bACPred = OMX_FALSE;
  2185
+        }
  2186
+    }
  2187
+#endif
1258 2188
     mpeg4type.nTimeIncRes = 1000;
1259 2189
     mpeg4type.nHeaderExtension = 0;
1260 2190
     mpeg4type.bReversibleVLC = OMX_FALSE;
... ...
@@ -1267,6 +2197,9 @@ status_t OMXCodec::setupMPEG4EncoderParameters(const sp<MetaData>& meta) {
1267 2197
     if (err != OK) return err;
1268 2198
     mpeg4type.eProfile = static_cast<OMX_VIDEO_MPEG4PROFILETYPE>(profileLevel.mProfile);
1269 2199
     mpeg4type.eLevel = static_cast<OMX_VIDEO_MPEG4LEVELTYPE>(profileLevel.mLevel);
  2200
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  2201
+    mpeg4type.eLevel = OMX_VIDEO_MPEG4Level5;
  2202
+#endif
1270 2203
 
1271 2204
     err = mOMX->setParameter(
1272 2205
             mNode, OMX_IndexParamVideoMpeg4, &mpeg4type, sizeof(mpeg4type));
... ...
@@ -1277,11 +2210,56 @@ status_t OMXCodec::setupMPEG4EncoderParameters(const sp<MetaData>& meta) {
1277 2210
     CHECK_EQ(setupBitRate(bitRate), OK);
1278 2211
     CHECK_EQ(setupErrorCorrectionParameters(), OK);
1279 2212
 
  2213
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  2214
+     //OMX_VIDEO_PARAM_MOTIONVECTORTYPE Settings
  2215
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE MotionVector;
  2216
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE RefreshParam;
  2217
+    InitOMXParams(&MotionVector);
  2218
+    MotionVector.nPortIndex = kPortIndexOutput;
  2219
+
  2220
+    err = mOMX->getParameter(
  2221
+            mNode, OMX_IndexParamVideoMotionVector, &MotionVector,sizeof(MotionVector));
  2222
+
  2223
+    MotionVector.nPortIndex = kPortIndexOutput;
  2224
+
  2225
+    // extra parameters - hardcoded
  2226
+    MotionVector.sXSearchRange = 16;
  2227
+    MotionVector.sYSearchRange = 16;
  2228
+    MotionVector.bFourMV =  OMX_FALSE;
  2229
+    MotionVector.eAccuracy =  OMX_Video_MotionVectorHalfPel ;
  2230
+    MotionVector.bUnrestrictedMVs = OMX_TRUE;
  2231
+
  2232
+    err = mOMX->setParameter(
  2233
+            mNode, OMX_IndexParamVideoMotionVector, &MotionVector,sizeof(MotionVector));
  2234
+
  2235
+    //OMX_VIDEO_PARAM_INTRAREFRESHTYPE Settings
  2236
+     InitOMXParams(&RefreshParam);
  2237
+    RefreshParam.nPortIndex = kPortIndexOutput;
  2238
+
  2239
+    err = mOMX->getParameter(
  2240
+            mNode, OMX_IndexParamVideoIntraRefresh, &RefreshParam,sizeof(RefreshParam));
  2241
+
  2242
+    // extra parameters - hardcoded based on PV defaults
  2243
+    RefreshParam.nPortIndex = kPortIndexOutput;
  2244
+    RefreshParam.eRefreshMode = OMX_VIDEO_IntraRefreshBoth;
  2245
+
  2246
+    if(((width >= 640) || (height >= 480)) && (frameRate > 15) && (bitRate > 2000000))
  2247
+    {
  2248
+        RefreshParam.nAirRef = 0;
  2249
+    }
  2250
+
  2251
+    err = mOMX->setParameter(mNode, OMX_IndexParamVideoIntraRefresh, &RefreshParam,sizeof(RefreshParam));
  2252
+#endif
  2253
+
1280 2254
     return OK;
1281 2255
 }
1282 2256
 
1283 2257
 status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
1284 2258
     int32_t iFramesInterval, frameRate, bitRate;
  2259
+
  2260
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  2261
+    OMX_VIDEO_PARAM_VBSMCTYPE VbsmcType;
  2262
+#endif
1285 2263
     bool success = meta->findInt32(kKeyBitRate, &bitRate);
1286 2264
     success = success && meta->findInt32(kKeySampleRate, &frameRate);
1287 2265
     success = success && meta->findInt32(kKeyIFramesInterval, &iFramesInterval);
... ...
@@ -1299,8 +2277,26 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
1299 2277
         OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
1300 2278
 
1301 2279
     h264type.nSliceHeaderSpacing = 0;
  2280
+
  2281
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2282
+    h264type.nBFrames = OMX_NUM_B_FRAMES;
  2283
+    h264type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
  2284
+
  2285
+#ifdef SUPPORT_B_FRAMES
  2286
+    int32_t remainder = h264type.nPFrames % (OMX_NUM_B_FRAMES + 1);
  2287
+    if(remainder)
  2288
+    {
  2289
+        LOGD("h264type.nPFrames=%d", (int) h264type.nPFrames);
  2290
+        h264type.nPFrames = h264type.nPFrames - remainder;
  2291
+        LOGD("adjusted to h264type.nPFrames=%d", (int) h264type.nPFrames);
  2292
+    }
  2293
+#endif
  2294
+
  2295
+#else
1302 2296
     h264type.nBFrames = 0;   // No B frames support yet
1303 2297
     h264type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
  2298
+#endif
  2299
+
1304 2300
     if (h264type.nPFrames == 0) {
1305 2301
         h264type.nAllowedPictureTypes = OMX_VIDEO_PictureTypeI;
1306 2302
     }
... ...
@@ -1311,16 +2307,34 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
1311 2307
     defaultProfileLevel.mLevel = h264type.eLevel;
1312 2308
     err = getVideoProfileLevel(meta, defaultProfileLevel, profileLevel);
1313 2309
     if (!(mQuirks & kCanNotSetVideoParameters) && err != OK) return err;
  2310
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2311
+    h264type.eProfile = OMX_VIDEO_AVCProfileHigh;
  2312
+    h264type.eLevel = OMX_VIDEO_AVCLevel4;
  2313
+    LOGV("h264type.eProfile=%d, h264type.eLevel=%d", h264type.eProfile, h264type.eLevel);
  2314
+#else
1314 2315
     h264type.eProfile = static_cast<OMX_VIDEO_AVCPROFILETYPE>(profileLevel.mProfile);
1315 2316
     h264type.eLevel = static_cast<OMX_VIDEO_AVCLEVELTYPE>(profileLevel.mLevel);
  2317
+#endif
1316 2318
 
1317  
-    if (h264type.eProfile == OMX_VIDEO_AVCProfileBaseline) {
  2319
+    if (h264type.eProfile == OMX_VIDEO_AVCProfileBaseline
  2320
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2321
+       || h264type.eProfile == OMX_VIDEO_AVCProfileMain
  2322
+       || h264type.eProfile == OMX_VIDEO_AVCProfileHigh
  2323
+#endif
  2324
+       ) {
1318 2325
         h264type.bUseHadamard = OMX_TRUE;
1319 2326
         h264type.nRefFrames = 1;
1320 2327
         h264type.nRefIdx10ActiveMinus1 = 0;
1321 2328
         h264type.nRefIdx11ActiveMinus1 = 0;
  2329
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2330
+        h264type.bEntropyCodingCABAC = OMX_TRUE;
  2331
+#else
1322 2332
         h264type.bEntropyCodingCABAC = OMX_FALSE;
  2333
+#endif
1323 2334
         h264type.bWeightedPPrediction = OMX_FALSE;
  2335
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2336
+        h264type.nWeightedBipredicitonMode = OMX_FALSE;
  2337
+#endif
1324 2338
         h264type.bconstIpred = OMX_FALSE;
1325 2339
         h264type.bDirect8x8Inference = OMX_FALSE;
1326 2340
         h264type.bDirectSpatialTemporal = OMX_FALSE;
... ...
@@ -1347,6 +2361,68 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
1347 2361
 
1348 2362
     CHECK_EQ(setupBitRate(bitRate), OK);
1349 2363
 
  2364
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  2365
+    //OMX_IndexParamVideoMotionVector+
  2366
+    OMX_VIDEO_PARAM_MOTIONVECTORTYPE MotionVector;
  2367
+    InitOMXParams(&MotionVector);
  2368
+    MotionVector.nPortIndex = kPortIndexOutput;
  2369
+
  2370
+    err = mOMX->getParameter(mNode, OMX_IndexParamVideoMotionVector, &MotionVector, sizeof(MotionVector));
  2371
+    CHECK_EQ(err, OK);
  2372
+
  2373
+    // extra parameters - hardcoded
  2374
+    MotionVector.sXSearchRange = 16;
  2375
+    MotionVector.sYSearchRange = 16;
  2376
+    MotionVector.sXSearchRange = 144; // Set Horizontal search range to 144
  2377
+    MotionVector.sYSearchRange = 32; // Set Vertical search range to 32
  2378
+    MotionVector.bFourMV =  OMX_FALSE;
  2379
+    MotionVector.eAccuracy = OMX_Video_MotionVectorQuarterPel; // hardcoded
  2380
+    MotionVector.bUnrestrictedMVs = OMX_TRUE;
  2381
+
  2382
+    err = mOMX->setParameter(mNode, OMX_IndexParamVideoMotionVector, &MotionVector, sizeof(MotionVector));
  2383
+    CHECK_EQ(err, OK);
  2384
+
  2385
+    //OMX_IndexParamVideoIntraRefresh+
  2386
+    OMX_VIDEO_PARAM_INTRAREFRESHTYPE RefreshParam;
  2387
+    InitOMXParams(&RefreshParam);
  2388
+    RefreshParam.nPortIndex = kPortIndexOutput;
  2389
+
  2390
+    err = mOMX->getParameter(mNode, OMX_IndexParamVideoIntraRefresh, &RefreshParam, sizeof(RefreshParam));
  2391
+    CHECK_EQ(err, OK);
  2392
+
  2393
+    // extra parameters - hardcoded
  2394
+    RefreshParam.nPortIndex = kPortIndexOutput;
  2395
+    RefreshParam.eRefreshMode = OMX_VIDEO_IntraRefreshMax;//OMX_VIDEO_IntraRefreshBoth;
  2396
+    RefreshParam.nCirMBs = 0; //TO DO: need to confirm again.
  2397
+
  2398
+    err = mOMX->setParameter(mNode, OMX_IndexParamVideoIntraRefresh, &RefreshParam, sizeof(RefreshParam));
  2399
+    CHECK_EQ(err, OK);
  2400
+
  2401
+    int32_t isS3DEnabled = false;
  2402
+    success = success && meta->findInt32(kKeyS3dSupported, &isS3DEnabled);
  2403
+    CHECK(success);
  2404
+
  2405
+    //OMX_TI_IndexParamVideoEncoderPreset+
  2406
+    CHECK_EQ(setupEncoderPresetParams(isS3DEnabled), OK);
  2407
+
  2408
+    //OMX_TI_IndexParamVideoFrameDataContentSettings+
  2409
+    if(isS3DEnabled)
  2410
+        CHECK_EQ(setupEncoderFrameDataContentParams(meta), OK);
  2411
+
  2412
+    //OMX_IndexParamVideoVBSMC+
  2413
+    InitOMXParams(&VbsmcType);
  2414
+    VbsmcType.nPortIndex = kPortIndexOutput;
  2415
+
  2416
+    err = mOMX->getParameter(mNode, OMX_IndexParamVideoVBSMC, &VbsmcType,sizeof(VbsmcType));
  2417
+    CHECK_EQ(err, OK);
  2418
+
  2419
+    VbsmcType.b16x16 = OMX_TRUE;
  2420
+    VbsmcType.b16x8 = VbsmcType.b8x16 = VbsmcType.b8x8 = VbsmcType.b8x4 = VbsmcType.b4x8 = VbsmcType.b4x4 = OMX_FALSE;
  2421
+
  2422
+    err =mOMX->setParameter(mNode, OMX_IndexParamVideoVBSMC, &VbsmcType,sizeof(VbsmcType));
  2423
+    CHECK_EQ(err, OK);
  2424
+#endif
  2425
+
1350 2426
     return OK;
1351 2427
 }
1352 2428
 
... ...
@@ -1361,6 +2437,18 @@ status_t OMXCodec::setVideoOutputFormat(
1361 2437
         compressionFormat = OMX_VIDEO_CodingMPEG4;
1362 2438
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_H263, mime)) {
1363 2439
         compressionFormat = OMX_VIDEO_CodingH263;
  2440
+#if defined(OMAP_ENHANCEMENT)
  2441
+#if defined(TARGET_OMAP4)
  2442
+    } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_VP6, mime)) {
  2443
+        compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6;
  2444
+    } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_VP7, mime)) {
  2445
+        compressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP7;
  2446
+#endif
  2447
+    }
  2448
+    else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_WMV , mime))
  2449
+    {
  2450
+        compressionFormat = OMX_VIDEO_CodingWMV;
  2451
+#endif
1364 2452
     } else {
1365 2453
         LOGE("Not a supported video mime type: %s", mime);
1366 2454
         CHECK(!"Should not be here. Not a supported video mime type.");
... ...
@@ -1419,6 +2507,9 @@ status_t OMXCodec::setVideoOutputFormat(
1419 2507
                || format.eColorFormat == OMX_COLOR_FormatCbYCrY
1420 2508
                || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar
1421 2509
                || format.eColorFormat == QOMX_COLOR_FormatYVU420PackedSemiPlanar32m4ka
  2510
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2511
+               || format.eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar
  2512
+#endif
1422 2513
                || format.eColorFormat == QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka);
1423 2514
 
1424 2515
         err = mOMX->setParameter(
... ...
@@ -1442,6 +2533,18 @@ status_t OMXCodec::setVideoOutputFormat(
1442 2533
 
1443 2534
     CHECK_EQ(err, OK);
1444 2535
 
  2536
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2537
+    if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
  2538
+                //update input buffer size as per resolution
  2539
+                def.nBufferSize = width * height;
  2540
+
  2541
+         if(mQuirks & OMXCodec::kThumbnailMode){
  2542
+                def.nBufferCountActual = 1;
  2543
+         }else{
  2544
+                def.nBufferCountActual = 4;
  2545
+    }
  2546
+    }
  2547
+#else
1445 2548
 #if 1
1446 2549
     // XXX Need a (much) better heuristic to compute input buffer sizes.
1447 2550
     const size_t X = 64 * 1024;
... ...
@@ -1449,6 +2552,7 @@ status_t OMXCodec::setVideoOutputFormat(
1449 2552
         def.nBufferSize = X;
1450 2553
     }
1451 2554
 #endif
  2555
+#endif
1452 2556
 
1453 2557
     CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
1454 2558
 
... ...
@@ -1480,12 +2584,102 @@ status_t OMXCodec::setVideoOutputFormat(
1480 2584
         (((width + 15) & -16) * ((height + 15) & -16) * 3) / 2;  // YUV420
1481 2585
 #endif
1482 2586
 
  2587
+#if defined(OMAP_ENHANCEMENT)
  2588
+#if defined(TARGET_OMAP4)
  2589
+    if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
  2590
+
  2591
+        OMX_CONFIG_RECTTYPE tParamStruct;
  2592
+        InitOMXParams(&tParamStruct);
  2593
+        tParamStruct.nPortIndex = kPortIndexOutput;
  2594
+
  2595
+        err = mOMX->getParameter(
  2596
+                mNode, (OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, &tParamStruct, sizeof(tParamStruct));
  2597
+
  2598
+        CHECK_EQ(err, OK);
  2599
+
  2600
+        video_def->nStride = tParamStruct.nWidth;
  2601
+        mStride = video_def->nStride ;
  2602
+
  2603
+        if(mQuirks & kInterlacedOutputContent){
  2604
+            video_def->eColorFormat = (OMX_COLOR_FORMATTYPE) OMX_TI_COLOR_FormatYUV420PackedSemiPlanar_Sequential_TopBottom;
  2605
+        }
  2606
+
  2607
+        video_def->xFramerate = mVideoFPS << 16;
  2608
+    }
  2609
+
  2610
+    if(!(mQuirks & OMXCodec::kThumbnailMode)){
  2611
+            //playback usecase. Calculate the buffer count to take display optimal buffer count into account
  2612
+            //Note: this is applicable for both ducati and h/w codecs
  2613
+            //def.nBufferCountMin    => minimum no of buffers required on a port (communicated by codec)
  2614
+            //def.nBufferCountActual => actual no. of buffers allocated on a port (communicated to codec)
  2615
+            def.nBufferCountActual = def.nBufferCountMin + (2 * NUM_BUFFERS_TO_BE_QUEUED_FOR_OPTIMAL_PERFORMANCE);
  2616
+    }
  2617
+#elif defined(TARGET_OMAP3)
  2618
+    // Suppress output buffer count for OMAP3
  2619
+    // The number of VRFB buffer, which is used for rotation, is 4.
  2620
+    // Output buffer count can not exceed VRFB buffer count.
  2621
+    if (def.nBufferCountActual > OUTPUT_BUFFER_COUNT)
  2622
+        def.nBufferCountActual = OUTPUT_BUFFER_COUNT;
  2623
+#endif
  2624
+#endif
1483 2625
     video_def->nFrameWidth = width;
1484 2626
     video_def->nFrameHeight = height;
1485 2627
 
1486 2628
     err = mOMX->setParameter(
1487 2629
             mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
1488 2630
 
  2631
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2632
+    if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")) {
  2633
+
  2634
+        if(mQuirks & OMXCodec::kThumbnailMode){
  2635
+
  2636
+            LOGD("Thumbnail Mode");
  2637
+            //Get the calculated min buffer count
  2638
+            err = mOMX->getParameter(
  2639
+                    mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  2640
+            CHECK_EQ(err, OK);
  2641
+            CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
  2642
+
  2643
+            //Thumbnail usecase. Set buffer count to optimal
  2644
+            def.nBufferCountActual = def.nBufferCountMin;
  2645
+
  2646
+            //Set the proper parameters again, as it is marshalled in Get_Parameter()
  2647
+            video_def->nFrameWidth = width;
  2648
+            video_def->nFrameHeight = height;
  2649
+
  2650
+            err = mOMX->setParameter(
  2651
+                    mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  2652
+            CHECK_EQ(err, OK);
  2653
+
  2654
+#if defined (NPA_BUFFERS)
  2655
+            CODEC_LOGV("Setting up the non-pre-annoucement mode");
  2656
+            OMX_TI_PARAM_BUFFERPREANNOUNCE PreAnnouncement;
  2657
+            InitOMXParams(&PreAnnouncement);
  2658
+            PreAnnouncement.nPortIndex = def.nPortIndex;
  2659
+            err = mOMX->getParameter(
  2660
+                    mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamBufferPreAnnouncement, &PreAnnouncement, sizeof(PreAnnouncement));
  2661
+               if (err != OMX_ErrorNone)
  2662
+            {
  2663
+                CODEC_LOGE("get OMX_TI_IndexParamBufferPreAnnouncement err : %x",err);
  2664
+            }
  2665
+
  2666
+            //Set the pre-annoucement to be false. i.e we will provide the buffer when we get it from camera.
  2667
+            PreAnnouncement.bEnabled = OMX_FALSE;
  2668
+            err = mOMX->setParameter(
  2669
+                    mNode, (OMX_INDEXTYPE)OMX_TI_IndexParamBufferPreAnnouncement, &PreAnnouncement, sizeof(PreAnnouncement));
  2670
+            if (err != OMX_ErrorNone)
  2671
+            {
  2672
+                CODEC_LOGE("set OMX_TI_IndexParamBufferPreAnnouncement err : %x",err);
  2673
+            }
  2674
+
  2675
+            mNumberOfNPABuffersSent = 0;
  2676
+            mThumbnailEOSSent = 0;
  2677
+#endif
  2678
+
  2679
+        }
  2680
+   }
  2681
+#endif
  2682
+
1489 2683
     return err;
1490 2684
 }
1491 2685
 
... ...
@@ -1547,6 +2741,22 @@ void OMXCodec::setComponentRole(
1547 2741
             "video_decoder.mpeg4", "video_encoder.mpeg4" },
1548 2742
         { MEDIA_MIMETYPE_VIDEO_H263,
1549 2743
             "video_decoder.h263", "video_encoder.h263" },
  2744
+#if defined(OMAP_ENHANCEMENT)
  2745
+#if defined(TARGET_OMAP4)
  2746
+        { MEDIA_MIMETYPE_VIDEO_VP6,
  2747
+            "video_decoder.vp6", NULL },
  2748
+        { MEDIA_MIMETYPE_VIDEO_VP7,
  2749
+            "video_decoder.vp7", NULL },
  2750
+#endif
  2751
+        { MEDIA_MIMETYPE_VIDEO_WMV,
  2752
+            "video_decoder.wmv", "video_encoder.wmv" },
  2753
+        { MEDIA_MIMETYPE_AUDIO_WMA,
  2754
+            "audio_decoder.wma", "audio_encoder.wma" },
  2755
+        { MEDIA_MIMETYPE_AUDIO_WMAPRO,
  2756
+            "audio_decoder.wmapro", "audio_encoder.wmapro" },
  2757
+        { MEDIA_MIMETYPE_AUDIO_WMALSL,
  2758
+            "audio_decoder.wmalsl", "audio_encoder.wmalsl" },
  2759
+#endif
1550 2760
     };
1551 2761
 
1552 2762
     static const size_t kNumMimeToRole =
... ...
@@ -1675,7 +2885,40 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
1675 2885
             portIndex == kPortIndexInput ? "input" : "output");
1676 2886
 
1677 2887
     size_t totalSize = def.nBufferCountActual * ((def.nBufferSize + 31) & (~31));
  2888
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4) && defined (NPA_BUFFERS)
  2889
+            if( !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER") &&
  2890
+                (mQuirks & OMXCodec::kThumbnailMode) &&
  2891
+                (portIndex == kPortIndexOutput)){
  2892
+            totalSize = (THUMBNAIL_BUFFERS_NPA_MODE * def.nBufferSize)
  2893
+                        + ((def.nBufferCountActual - THUMBNAIL_BUFFERS_NPA_MODE) * NPA_BUFFER_SIZE);
  2894
+            }
  2895
+#endif
  2896
+
  2897
+#ifdef OMAP_ENHANCEMENT
  2898
+    bool useExternallyAllocatedBuffers = false;
  2899
+
  2900
+    if ((!strcmp(mComponentName, "OMX.TI.Video.Decoder") ||
  2901
+         !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER") ||
  2902
+         !strcmp(mComponentName, "OMX.TI.720P.Decoder")) &&
  2903
+        (portIndex == kPortIndexOutput) &&
  2904
+        (mExtBufferAddresses.size() == def.nBufferCountActual)
  2905
+#if defined(TARGET_OMAP4)
  2906
+        && !(mQuirks & OMXCodec::kThumbnailMode)
  2907
+#endif
  2908
+        ){
  2909
+
  2910
+        // One must use overlay buffers for TI video decoder output port.
  2911
+        // So, do not allocate memory here.
  2912
+        useExternallyAllocatedBuffers = true;
  2913
+    }
  2914
+    else{
  2915
+        mDealer[portIndex] = new MemoryDealer(totalSize, "OMXCodec");
  2916
+    }
  2917
+
  2918
+    sp<IMemory> mem;
  2919
+#else
1678 2920
     mDealer[portIndex] = new MemoryDealer(totalSize, "OMXCodec");
  2921
+#endif
1679 2922
 
1680 2923
 #ifdef USE_GETBUFFERINFO
1681 2924
     sp<IMemoryHeap> pFrameHeap = NULL;
... ...
@@ -1713,12 +2956,54 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
1713 2956
 #endif
1714 2957
 
1715 2958
     for (OMX_U32 i = 0; i < def.nBufferCountActual; ++i) {
  2959
+#ifdef OMAP_ENHANCEMENT
  2960
+        if (useExternallyAllocatedBuffers){
  2961
+            mem = mExtBufferAddresses[i];
  2962
+        }
  2963
+        else{
  2964
+
  2965
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4) && defined (NPA_BUFFERS)
  2966
+            if( !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER") &&
  2967
+                (mQuirks & OMXCodec::kThumbnailMode) &&
  2968
+                (portIndex == kPortIndexOutput) &&
  2969
+                (i>=THUMBNAIL_BUFFERS_NPA_MODE))
  2970
+                mem = mDealer[portIndex]->allocate(NPA_BUFFER_SIZE);
  2971
+            else
  2972
+#endif
  2973
+            {
  2974
+                if(portIndex == kPortIndexOutput)
  2975
+                {
  2976
+                    def.nBufferSize = ((def.nBufferSize + CACHELINE_BOUNDARY_MEMALIGNMENT - 1) &
  2977
+                      ~(CACHELINE_BOUNDARY_MEMALIGNMENT - 1));
  2978
+                }
  2979
+                mem = mDealer[portIndex]->allocate(def.nBufferSize);
  2980
+            }
  2981
+        }
  2982
+#else
1716 2983
         sp<IMemory> mem = mDealer[portIndex]->allocate(def.nBufferSize);
  2984
+#endif
1717 2985
         CHECK(mem.get() != NULL);
1718 2986
 
1719 2987
         BufferInfo info;
1720 2988
         info.mData = NULL;
1721 2989
         info.mSize = def.nBufferSize;
  2990
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  2991
+        //Update Output buffers range as per 2D buffer requirement.
  2992
+        //Doubling size to contain (nFilledLen + nOffset) check. Extra range is harmless here.
  2993
+        if (!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")){
  2994
+            if(useExternallyAllocatedBuffers)
  2995
+            {
  2996
+                OMX_VIDEO_PORTDEFINITIONTYPE *videoDef = &def.format.video;
  2997
+                int32_t padded_height;
  2998
+
  2999
+                if (!(mOutputFormat->findInt32(kKeyPaddedHeight, &padded_height))) {
  3000
+                    padded_height =  videoDef->nFrameHeight;
  3001
+                }
  3002
+
  3003
+                info.mSize = ARM_4K_PAGE_SIZE * padded_height * 2;
  3004
+            }
  3005
+        }
  3006
+#endif
1722 3007
 
1723 3008
         IOMX::buffer_id buffer;
1724 3009
         if (portIndex == kPortIndexInput
... ...
@@ -1746,7 +3031,18 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
1746 3031
                         mNode, portIndex, mem, &buffer);
1747 3032
             }
1748 3033
         } else {
1749  
-#ifdef USE_GETBUFFERINFO
  3034
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  3035
+                if((!strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E")
  3036
+                                        || !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E"))
  3037
+                                && (portIndex == kPortIndexInput)
  3038
+                                && !(mQuirks & kRequiresAllocateBufferOnInputPorts) ){
  3039
+                        sp<IMemory> tempmem = mem;
  3040
+                        tempmem.clear();
  3041
+                        err = mOMX->useBuffer(mNode, portIndex, tempmem, &buffer, mem->size());
  3042
+                } else {
  3043
+                        err = mOMX->useBuffer(mNode, portIndex, mem, &buffer, mem->size());
  3044
+                }
  3045
+#elif defined(USE_GETBUFFERINFO)
1750 3046
             if(pFrameHeap != NULL && mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames)) {
1751 3047
                 ssize_t temp_offset = i * alignedSize;
1752 3048
                 size_t temp_size = size;
... ...
@@ -1758,10 +3054,11 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
1758 3054
                     temp_size, alignedSize, pFrame->pointer(), pFrameHeap->getSize());
1759 3055
                 err = mOMX->useBuffer(mNode, portIndex, pFrame, &buffer);
1760 3056
             } else
1761  
-#endif
  3057
+#else
1762 3058
             {
1763 3059
                 err = mOMX->useBuffer(mNode, portIndex, mem, &buffer);
1764 3060
             }
  3061
+#endif
1765 3062
         }
1766 3063
 
1767 3064
         if (err != OK) {
... ...
@@ -1775,6 +3072,9 @@ status_t OMXCodec::allocateBuffersOnPort(OMX_U32 portIndex) {
1775 3072
 
1776 3073
         info.mBuffer = buffer;
1777 3074
         info.mOwnedByComponent = false;
  3075
+#ifdef OMAP_ENHANCEMENT
  3076
+        info.mOwnedByPlayer = false;
  3077
+#endif
1778 3078
         info.mMem = mem;
1779 3079
         info.mMediaBuffer = NULL;
1780 3080
 
... ...
@@ -1901,6 +3201,13 @@ void OMXCodec::on_message(const omx_message &msg) {
1901 3201
                      "a FILL_BUFFER_DONE.", buffer);
1902 3202
             }
1903 3203
 
  3204
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4) && defined (NPA_BUFFERS)
  3205
+        if( !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER") &&
  3206
+            (mQuirks & OMXCodec::kThumbnailMode) ){
  3207
+            if (mNumberOfNPABuffersSent > 0)
  3208
+                mNumberOfNPABuffersSent--;
  3209
+        }
  3210
+#endif
1904 3211
             info->mOwnedByComponent = false;
1905 3212
 
1906 3213
             if (mPortStatus[kPortIndexOutput] == DISABLING) {
... ...
@@ -1960,6 +3267,9 @@ void OMXCodec::on_message(const omx_message &msg) {
1960 3267
 
1961 3268
                 buffer->meta_data()->clear();
1962 3269
 
  3270
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  3271
+                buffer->meta_data()->setInt32(kKeyStride, mStride);
  3272
+#endif
1963 3273
                 buffer->meta_data()->setInt64(
1964 3274
                         kKeyTime, msg.u.extended_buffer_data.timestamp);
1965 3275
 
... ...
@@ -1970,6 +3280,11 @@ void OMXCodec::on_message(const omx_message &msg) {
1970 3280
                     buffer->meta_data()->setInt32(kKeyIsCodecConfig, true);
1971 3281
                 }
1972 3282
 
  3283
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  3284
+                if (msg.u.extended_buffer_data.flags & OMX_TI_BUFFERFLAG_DETACHEDEXTRADATA)
  3285
+                    buffer->meta_data()->setInt32(kKeyIsExtraData, true);
  3286
+#endif
  3287
+
1973 3288
                 if (mQuirks & kOutputBuffersAreUnreadable) {
1974 3289
                     buffer->meta_data()->setInt32(kKeyIsUnreadable, true);
1975 3290
                 }
... ...
@@ -1986,7 +3301,6 @@ void OMXCodec::on_message(const omx_message &msg) {
1986 3301
                     CODEC_LOGV("No more output data.");
1987 3302
                     mNoMoreOutputData = true;
1988 3303
                 }
1989  
-
1990 3304
                 if (mTargetTimeUs >= 0) {
1991 3305
                     CHECK(msg.u.extended_buffer_data.timestamp <= mTargetTimeUs);
1992 3306
 
... ...
@@ -2059,6 +3373,7 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
2059 3373
 
2060 3374
         case OMX_EventPortSettingsChanged:
2061 3375
         {
  3376
+#ifndef OMAP_ENHANCEMENT
2062 3377
             if(mState == EXECUTING)
2063 3378
                 CODEC_LOGV("OMX_EventPortSettingsChanged(port=%ld, data2=0x%08lx)",
2064 3379
                        data1, data2);
... ...
@@ -2071,6 +3386,9 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
2071 3386
                 }
2072 3387
             else
2073 3388
               LOGE("Ignore PortSettingsChanged event \n");
  3389
+#else
  3390
+            onPortSettingsChanged(data1);
  3391
+#endif
2074 3392
             break;
2075 3393
         }
2076 3394
 
... ...
@@ -2192,10 +3510,57 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
2192 3510
                 mOutputPortSettingsHaveChanged =
2193 3511
                     formatHasNotablyChanged(oldOutputFormat, mOutputFormat);
2194 3512
 
  3513
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  3514
+                if( !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")){
  3515
+                    if (mExtBufferAddresses.size() == 0) /* Any Ducati codec non-overlay usecase */
  3516
+                    {
  3517
+                        LOGD("OMX_CommandPortDisable Done. Reenabling port for non-overlay playback usecase");
  3518
+
  3519
+                        /*Since we are mostly dealing 1D buffers here,
  3520
+                          nStride has to be updated as nFrameWidth will change on portreconfig
  3521
+                          */
  3522
+                        OMX_PARAM_PORTDEFINITIONTYPE def;
  3523
+                        InitOMXParams(&def);
  3524
+                        def.nPortIndex = kPortIndexOutput;
  3525
+
  3526
+                        status_t err = mOMX->getParameter(
  3527
+                              mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  3528
+                        CHECK_EQ(err, OK);
  3529
+
  3530
+                        OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video;
  3531
+
  3532
+                        int32_t padded_width;
  3533
+                        CHECK(mOutputFormat->findInt32(kKeyPaddedWidth, &padded_width));
  3534
+                        video_def->nStride = padded_width;
  3535
+                        mStride = video_def->nStride;
  3536
+
  3537
+                        LOGE("Updating video_def->nStride with new width %d", (int) video_def->nStride);
  3538
+
  3539
+                        err = mOMX->setParameter(
  3540
+                                     mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  3541
+
  3542
+
  3543
+                        enablePortAsync(portIndex);
  3544
+
  3545
+                        err = allocateBuffersOnPort(portIndex);
  3546
+                        CHECK_EQ(err, OK);
  3547
+                   }else
  3548
+                   {
  3549
+                      LOGD("OMX_CommandPortDisable Done. Not enabling port till overlay buffers are available");
  3550
+                   }
  3551
+                } else
  3552
+                {
2195 3553
                 enablePortAsync(portIndex);
2196 3554
 
2197 3555
                 status_t err = allocateBuffersOnPort(portIndex);
2198 3556
                 CHECK_EQ(err, OK);
  3557
+                }
  3558
+#else
  3559
+                enablePortAsync(portIndex);
  3560
+
  3561
+                status_t err = allocateBuffersOnPort(portIndex);
  3562
+                CHECK_EQ(err, OK);
  3563
+#endif
2199 3564
             }
2200 3565
             break;
2201 3566
         }
... ...
@@ -2338,6 +3703,12 @@ void OMXCodec::onStateChange(OMX_STATETYPE newState) {
2338 3703
 
2339 3704
         case OMX_StateLoaded:
2340 3705
         {
  3706
+#ifdef OMAP_ENHANCEMENT
  3707
+            if(LOADED == mState)
  3708
+            {
  3709
+                break;
  3710
+            }
  3711
+#endif
2341 3712
             CHECK_EQ(mState, IDLE_TO_LOADED);
2342 3713
 
2343 3714
             CODEC_LOGV("Now Loaded.");
... ...
@@ -2381,7 +3752,11 @@ status_t OMXCodec::freeBuffersOnPort(
2381 3752
     for (size_t i = buffers->size(); i-- > 0;) {
2382 3753
         BufferInfo *info = &buffers->editItemAt(i);
2383 3754
 
2384  
-        if (onlyThoseWeOwn && info->mOwnedByComponent) {
  3755
+#ifdef OMAP_ENHANCEMENT
  3756
+        if (onlyThoseWeOwn && (info->mOwnedByComponent || info->mOwnedByPlayer) ) {
  3757
+#else
  3758
+        if (onlyThoseWeOwn && info->mOwnedByComponent ) {
  3759
+#endif
2385 3760
             continue;
2386 3761
         }
2387 3762
 
... ...
@@ -2421,6 +3796,34 @@ void OMXCodec::onPortSettingsChanged(OMX_U32 portIndex) {
2421 3796
     CHECK_EQ(portIndex, kPortIndexOutput);
2422 3797
     setState(RECONFIGURING);
2423 3798
 
  3799
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  3800
+    LOGD("[%s] PORT_SETTINGS_CHANGED(%d)",mComponentName, (int)portIndex);
  3801
+
  3802
+#if defined (NPA_BUFFERS)
  3803
+    //reset NPA buffer counter on port reconfig.
  3804
+    mNumberOfNPABuffersSent = 0;
  3805
+  mThumbnailEOSSent = 0;
  3806
+#endif
  3807
+
  3808
+    if( !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER"))
  3809
+    {
  3810
+        /* update new port settings, since renderer needs new WxH for new buffers */
  3811
+        initOutputFormat(mSource->getFormat());
  3812
+
  3813
+        /* For thumbnail color conversion routine will require unpadded display WxH
  3814
+           update it in video-source meta data here, to be used later during color conversion */
  3815
+        OMX_PARAM_PORTDEFINITIONTYPE def;
  3816
+        InitOMXParams(&def);
  3817
+        def.nPortIndex = kPortIndexOutput;
  3818
+        status_t err = mOMX->getParameter(
  3819
+                mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  3820
+        CHECK_EQ(err, OK);
  3821
+        OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video;
  3822
+        mSource->getFormat()->setInt32(kKeyWidth, video_def->nFrameWidth);
  3823
+        mSource->getFormat()->setInt32(kKeyHeight, video_def->nFrameHeight);
  3824
+        LOGI("Updated source WxH %dx%d", (int) video_def->nFrameWidth, (int) video_def->nFrameHeight);
  3825
+    }
  3826
+#endif
2424 3827
     if (mQuirks & kNeedsFlushBeforeDisable) {
2425 3828
         if (!flushPortAsync(portIndex)) {
2426 3829
             onCmdComplete(OMX_CommandFlush, portIndex);
... ...
@@ -2459,7 +3862,6 @@ bool OMXCodec::flushPortAsync(OMX_U32 portIndex) {
2459 3862
 
2460 3863
 void OMXCodec::disablePortAsync(OMX_U32 portIndex) {
2461 3864
     CHECK(mState == EXECUTING || mState == RECONFIGURING);
2462  
-
2463 3865
     CHECK_EQ(mPortStatus[portIndex], ENABLED);
2464 3866
     mPortStatus[portIndex] = DISABLING;
2465 3867
 
... ...
@@ -2501,7 +3903,26 @@ void OMXCodec::fillOutputBuffers() {
2501 3903
 
2502 3904
     Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexOutput];
2503 3905
     for (size_t i = 0; i < buffers->size(); ++i) {
  3906
+#ifdef OMAP_ENHANCEMENT
  3907
+        if ((*buffers)[i].mOwnedByPlayer) {
  3908
+            continue;
  3909
+        }
  3910
+#endif
  3911
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  3912
+        if (!(*buffers)[i].mOwnedByComponent) {
  3913
+
  3914
+#if defined (NPA_BUFFERS)
  3915
+        if( !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER") &&
  3916
+            (mQuirks & OMXCodec::kThumbnailMode) ){
  3917
+            if(mNumberOfNPABuffersSent++ >= THUMBNAIL_BUFFERS_NPA_MODE)
  3918
+                return;
  3919
+        }
  3920
+#endif
  3921
+            fillOutputBuffer(&buffers->editItemAt(i));
  3922
+        }
  3923
+#else
2504 3924
         fillOutputBuffer(&buffers->editItemAt(i));
  3925
+#endif
2505 3926
     }
2506 3927
 }
2507 3928
 
... ...
@@ -2516,8 +3937,13 @@ void OMXCodec::drainInputBuffers() {
2516 3937
         //and camera will not give any more unless we give release
2517 3938
         if (mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames) && (i == 4))
2518 3939
             break;
2519  
-#endif
  3940
+#elif defined(OMAP_ENHANCEMENT)
  3941
+        if (!(*buffers)[i].mOwnedByComponent) {
  3942
+            drainInputBuffer(&buffers->editItemAt(i));
  3943
+        }
  3944
+#else
2520 3945
         drainInputBuffer(&buffers->editItemAt(i));
  3946
+#endif
2521 3947
     }
2522 3948
 }
2523 3949
 
... ...
@@ -2555,14 +3981,13 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
2555 3981
 
2556 3982
         CODEC_LOGV("calling emptyBuffer with codec specific data");
2557 3983
 
  3984
+        info->mOwnedByComponent = true;
2558 3985
         status_t err = mOMX->emptyBuffer(
2559 3986
                 mNode, info->mBuffer, 0, size,
2560 3987
                 OMX_BUFFERFLAG_ENDOFFRAME | OMX_BUFFERFLAG_CODECCONFIG,
2561 3988
                 0);
2562 3989
         CHECK_EQ(err, OK);
2563 3990
 
2564  
-        info->mOwnedByComponent = true;
2565  
-
2566 3991
         ++mCodecSpecificDataIndex;
2567 3992
         return;
2568 3993
     }
... ...
@@ -2578,9 +4003,20 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
2578 4003
 
2579 4004
     size_t offset = 0;
2580 4005
     int32_t n = 0;
  4006
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  4007
+    uint32_t omx_offset = 0;
  4008
+#endif
  4009
+
2581 4010
     for (;;) {
2582 4011
         MediaBuffer *srcBuffer;
2583 4012
         MediaSource::ReadOptions options;
  4013
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  4014
+        MediaBuffer *tmpBuffer = NULL;
  4015
+        if (!mIsEncoder) {
  4016
+            srcBuffer = new MediaBuffer(info->mData, info->mSize);
  4017
+            tmpBuffer = srcBuffer;
  4018
+        }
  4019
+#endif
2584 4020
         if (mSkipTimeUs >= 0) {
2585 4021
             options.setSkipFrame(mSkipTimeUs);
2586 4022
         }
... ...
@@ -2617,6 +4053,17 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
2617 4053
         }
2618 4054
 
2619 4055
         if (err != OK) {
  4056
+#ifdef OMAP_ENHANCEMENT
  4057
+            if(mQuirks & kDecoderCantRenderSmallClips &&
  4058
+               err == ERROR_END_OF_STREAM){
  4059
+                static char mBufferAfterEos = 0;
  4060
+                if(!mBufferAfterEos){
  4061
+                    mBufferAfterEos = 1;
  4062
+                    break;
  4063
+                }
  4064
+                mBufferAfterEos = 0;
  4065
+            }
  4066
+#endif
2620 4067
             signalEOS = true;
2621 4068
             mFinalStatus = err;
2622 4069
             mSignalledEOS = true;
... ...
@@ -2651,14 +4098,34 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
2651 4098
             CHECK(mOMXLivesLocally && offset == 0);
2652 4099
             OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *) info->mBuffer;
2653 4100
             header->pBuffer = (OMX_U8 *) srcBuffer->data() + srcBuffer->range_offset();
  4101
+#if defined (OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  4102
+            //closed loop.
  4103
+            if(!strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E")
  4104
+               || !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E")) {
  4105
+                srcBuffer->meta_data()->findInt32(kKeyOffset,(int32_t *) &omx_offset);
  4106
+            }
  4107
+
  4108
+            releaseBuffer = false;
  4109
+            info->mMediaBuffer = srcBuffer;
  4110
+#endif
2654 4111
         } else {
2655 4112
             if (mQuirks & kStoreMetaDataInInputVideoBuffers) {
2656 4113
                 releaseBuffer = false;
2657 4114
                 info->mMediaBuffer = srcBuffer;
2658 4115
             }
  4116
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  4117
+        if (tmpBuffer != srcBuffer) {
  4118
+            memcpy((uint8_t *)info->mData + offset,
  4119
+                    (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(),
  4120
+                    srcBuffer->range_length());
  4121
+            if (tmpBuffer)
  4122
+                tmpBuffer->release();
  4123
+        }
  4124
+#else
2659 4125
             memcpy((uint8_t *)info->mData + offset,
2660 4126
                     (const uint8_t *)srcBuffer->data() + srcBuffer->range_offset(),
2661 4127
                     srcBuffer->range_length());
  4128
+#endif
2662 4129
         }
2663 4130
 
2664 4131
         int64_t lastBufferTimeUs;
... ...
@@ -2697,6 +4164,30 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
2697 4164
     }
2698 4165
 
2699 4166
     OMX_U32 flags = OMX_BUFFERFLAG_ENDOFFRAME;
  4167
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4) && defined (NPA_BUFFERS)
  4168
+    if(mQuirks & OMXCodec::kThumbnailMode) {
  4169
+        CODEC_LOGV("Sending eos flag %d",mThumbnailEOSSent);
  4170
+        if(mThumbnailEOSSent == 1) {
  4171
+            CODEC_LOGV("Previously EOS was sent out for thumbnail mode");
  4172
+            // Returning for this point since we dont want to send
  4173
+            // any more input buffers to the codec as it is expected to
  4174
+            // flush out the frame from codec since we have send EOS
  4175
+            // flag in input previous buffer.
  4176
+            return;
  4177
+        }
  4178
+        mThumbnailEOSSent = 1;
  4179
+        flags |= OMX_BUFFERFLAG_EOS;
  4180
+    }
  4181
+#endif
  4182
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  4183
+
  4184
+    if(!strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E")
  4185
+       || !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E"))
  4186
+    {
  4187
+        flags |= OMX_BUFFERFLAG_SYNCFRAME;
  4188
+        flags |= OMX_BUFFERHEADERFLAG_MODIFIED;
  4189
+    }
  4190
+#endif
2700 4191
 
2701 4192
     if (signalEOS) {
2702 4193
         flags |= OMX_BUFFERFLAG_EOS;
... ...
@@ -2709,20 +4200,36 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
2709 4200
                info->mBuffer, offset,
2710 4201
                timestampUs, timestampUs / 1E6);
2711 4202
 
  4203
+    info->mOwnedByComponent = true;
  4204
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  4205
+    if(!strcmp(mComponentName,"OMX.TI.DUCATI1.VIDEO.H264E")
  4206
+       || !strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.MPEG4E")) {
  4207
+        CODEC_LOGV("Calling emptybuffer with offset value =%ld ",omx_offset);
  4208
+
  4209
+        err = mOMX->emptyBuffer(
  4210
+            mNode, info->mBuffer, omx_offset, offset,
  4211
+            flags, timestampUs);
  4212
+    } else {
  4213
+        err = mOMX->emptyBuffer(
  4214
+            mNode, info->mBuffer, 0, offset,
  4215
+            flags, timestampUs);
  4216
+    }
  4217
+#else
2712 4218
     err = mOMX->emptyBuffer(
2713 4219
             mNode, info->mBuffer, 0, offset,
2714 4220
             flags, timestampUs);
  4221
+#endif
2715 4222
 
2716 4223
     if (err != OK) {
2717 4224
         setState(ERROR);
2718 4225
         return;
2719 4226
     }
2720 4227
 
2721  
-    info->mOwnedByComponent = true;
2722  
-
2723 4228
     // This component does not ever signal the EOS flag on output buffers,
2724 4229
     // Thanks for nothing.
2725  
-    if (mSignalledEOS && !strcmp(mComponentName, "OMX.TI.Video.encoder")) {
  4230
+    if (mSignalledEOS &&
  4231
+            (!strcmp(mComponentName, "OMX.TI.Video.encoder") ||
  4232
+             !strcmp(mComponentName, "OMX.TI.720P.Encoder"))) {
2726 4233
         mNoMoreOutputData = true;
2727 4234
         mBufferFilled.signal();
2728 4235
     }
... ...
@@ -2738,6 +4245,7 @@ void OMXCodec::fillOutputBuffer(BufferInfo *info) {
2738 4245
     }
2739 4246
 
2740 4247
     CODEC_LOGV("Calling fill_buffer on buffer %p", info->mBuffer);
  4248
+    info->mOwnedByComponent = true;
2741 4249
     status_t err = mOMX->fillBuffer(mNode, info->mBuffer);
2742 4250
 
2743 4251
     if (err != OK) {
... ...
@@ -2746,8 +4254,6 @@ void OMXCodec::fillOutputBuffer(BufferInfo *info) {
2746 4254
         setState(ERROR);
2747 4255
         return;
2748 4256
     }
2749  
-
2750  
-    info->mOwnedByComponent = true;
2751 4257
 }
2752 4258
 
2753 4259
 void OMXCodec::drainInputBuffer(IOMX::buffer_id buffer) {
... ...
@@ -2766,8 +4272,19 @@ void OMXCodec::fillOutputBuffer(IOMX::buffer_id buffer) {
2766 4272
     Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexOutput];
2767 4273
     for (size_t i = 0; i < buffers->size(); ++i) {
2768 4274
         if ((*buffers)[i].mBuffer == buffer) {
2769  
-            fillOutputBuffer(&buffers->editItemAt(i));
2770  
-            return;
  4275
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  4276
+            if (!(*buffers)[i].mOwnedByComponent) {
  4277
+                fillOutputBuffer(&buffers->editItemAt(i));
  4278
+                return;
  4279
+            }
  4280
+            else {
  4281
+                CODEC_LOGV("ALREADY OWNING THE BUFFER. RETURNING");
  4282
+                return;
  4283
+            }
  4284
+#else
  4285
+        fillOutputBuffer(&buffers->editItemAt(i));
  4286
+        return;
  4287
+#endif
2771 4288
         }
2772 4289
     }
2773 4290
 
... ...
@@ -3218,10 +4735,96 @@ sp<MetaData> OMXCodec::getFormat() {
3218 4735
     return mOutputFormat;
3219 4736
 }
3220 4737
 
  4738
+#ifdef OMAP_ENHANCEMENT
  4739
+void OMXCodec::setBuffers(Vector< sp<IMemory> > mBufferAddresses, bool portReconfig){
  4740
+    mExtBufferAddresses = mBufferAddresses;
  4741
+
  4742
+#ifdef TARGET_OMAP4
  4743
+    if(!portReconfig){
  4744
+
  4745
+        OMX_PARAM_PORTDEFINITIONTYPE def;
  4746
+        InitOMXParams(&def);
  4747
+        def.nPortIndex = kPortIndexOutput;
  4748
+
  4749
+        status_t err = mOMX->getParameter(
  4750
+                        mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  4751
+        CHECK_EQ(err, OK);
  4752
+        //reconfigure codec with the number of buffers actually got created
  4753
+        //by the Hardware Renderer
  4754
+        def.nBufferCountActual = mExtBufferAddresses.size();
  4755
+
  4756
+        //Update stride for 2D buffers
  4757
+        OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video;
  4758
+        video_def->nStride = ARM_4K_PAGE_SIZE;
  4759
+        mStride = video_def->nStride;
  4760
+
  4761
+        err = mOMX->setParameter(
  4762
+                     mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  4763
+        //CHECK_EQ(err, OK);
  4764
+    }else{
  4765
+
  4766
+        if(portReconfig && mState!= RECONFIGURING)
  4767
+        {
  4768
+            LOGE("Extra setbuffer(portreconfig=true) call when port reconfigure is done. REPORT THIS");
  4769
+            return;
  4770
+        }
  4771
+
  4772
+        // Wait till all fillbuffer done events are handled cleanly
  4773
+        usleep(10000); 
  4774
+
  4775
+        // Flush all the buffers
  4776
+        freeBuffersOnPort(kPortIndexOutput);
  4777
+
  4778
+        //disable the port if it enabled
  4779
+        if (mPortStatus[kPortIndexOutput] == ENABLED) {
  4780
+            disablePortAsync(kPortIndexOutput);
  4781
+        }
  4782
+
  4783
+        int32_t retrycount = 0;
  4784
+        while(mPortStatus[kPortIndexOutput] == DISABLING){
  4785
+            usleep(2000); // 2 mS
  4786
+            LOGD("(%d) Output port is DISABLING.. Waiting for port to be disabled.. %d",retrycount,mPortStatus[kPortIndexOutput] );
  4787
+            retrycount++;
  4788
+            CHECK(retrycount < 100);
  4789
+        }
  4790
+
  4791
+        OMX_PARAM_PORTDEFINITIONTYPE def;
  4792
+        InitOMXParams(&def);
  4793
+        def.nPortIndex = kPortIndexOutput;
  4794
+
  4795
+        status_t err = mOMX->getParameter(
  4796
+        mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  4797
+        CHECK_EQ(err, OK);
  4798
+
  4799
+        OMX_VIDEO_PORTDEFINITIONTYPE *video_def = &def.format.video;
  4800
+        video_def->nStride = 4096;
  4801
+        LOGE("Updating video_def->nStride with new width %d", (int) video_def->nStride);
  4802
+        err = mOMX->setParameter(mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  4803
+
  4804
+        /*output port is not enabled for ducati codecs, delayed till we get buffers here */
  4805
+        enablePortAsync(kPortIndexOutput);
  4806
+        allocateBuffersOnPort(kPortIndexOutput);
  4807
+
  4808
+        //Make sure output port is reached to ENABLED state and thus mstate to EXECUTING
  4809
+        retrycount = 0;
  4810
+        while(mPortStatus[kPortIndexOutput] == ENABLING){
  4811
+            usleep(2000); // 2 mS
  4812
+            LOGD("(%d) Output port is ENABLING.. Waiting for port to be enabled.. %d",retrycount,mPortStatus[kPortIndexOutput] );
  4813
+            retrycount++;
  4814
+            CHECK(retrycount < 100);
  4815
+        }
  4816
+    }
  4817
+#endif
  4818
+}
  4819
+#endif
  4820
+
3221 4821
 status_t OMXCodec::read(
3222 4822
         MediaBuffer **buffer, const ReadOptions *options) {
3223 4823
 
  4824
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
3224 4825
     status_t wait_status = 0;
  4826
+#endif
  4827
+
3225 4828
     *buffer = NULL;
3226 4829
 
3227 4830
     Mutex::Autolock autoLock(mLock);
... ...
@@ -3230,6 +4833,18 @@ status_t OMXCodec::read(
3230 4833
         return UNKNOWN_ERROR;
3231 4834
     }
3232 4835
 
  4836
+#if defined(OMAP_ENHANCEMENT) && defined (TARGET_OMAP4)
  4837
+    /*Stagefright port-reconfiguration logic is based on mOutputPortSettingsHaveChanged, which will be updated very late when port is reenabled */
  4838
+    /*Detect port-config event quickly so overlay buffers will be available upfront*/
  4839
+    if(!strcmp(mComponentName, "OMX.TI.DUCATI1.VIDEO.DECODER")){
  4840
+        if (mState == RECONFIGURING) {
  4841
+            mOutputPortSettingsHaveChanged = false;
  4842
+            mFilledBuffers.clear();
  4843
+            return INFO_FORMAT_CHANGED;
  4844
+        }
  4845
+    }
  4846
+#endif
  4847
+
3233 4848
     bool seeking = false;
3234 4849
     int64_t seekTimeUs;
3235 4850
     ReadOptions::SeekMode seekMode;
... ...
@@ -3291,21 +4906,94 @@ status_t OMXCodec::read(
3291 4906
         }
3292 4907
 
3293 4908
         while (mSeekTimeUs >= 0) {
3294  
-            wait_status = mBufferFilled.waitRelative(mLock, 3000000000);
  4909
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  4910
+            wait_status = (mNSecsToWait == 0) ? mBufferFilled.wait(mLock) : mBufferFilled.waitRelative(mLock, mNSecsToWait);
3295 4911
             if (wait_status) {
3296 4912
                 LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
3297 4913
                 return UNKNOWN_ERROR;
3298 4914
             }
  4915
+#else
  4916
+            mBufferFilled.wait(mLock);
  4917
+#endif
3299 4918
         }
3300 4919
     }
3301 4920
 
3302  
-    while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) {
3303  
-        wait_status = mBufferFilled.waitRelative(mLock, 3000000000);
  4921
+#ifdef OMAP_ENHANCEMENT
  4922
+    bool wasPaused = false;
  4923
+    if (mPaused) {
  4924
+        wasPaused = mPaused;
  4925
+        // We are resuming from the pause state. resetting the pause flag
  4926
+        mPaused = false;
  4927
+            /*Initiate the buffer flow on input port once again
  4928
+             * This is required to avoid starvation on I/P port if the
  4929
+             * previous empty_buffer_done calls are returned without
  4930
+             * initiating empty_buffer due to mpause was asserted.
  4931
+             * This needs to be done before waiting for the output buffer fill
  4932
+             * to avoid the deadlock
  4933
+             */
  4934
+            if (mState == EXECUTING) {
  4935
+                drainInputBuffers();
  4936
+            }
  4937
+    }
  4938
+#endif
  4939
+
  4940
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  4941
+    //only for OMAP4 Video decoder we shall check the buffers which are not with component
  4942
+    if (!strcmp("OMX.TI.DUCATI1.VIDEO.DECODER", mComponentName)) {
  4943
+        while (mState != RECONFIGURING && mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) {
  4944
+            CODEC_LOGV("READ LOCKED BUFFER QUEUE EMPTY FLAG : %d",mFilledBuffers.empty());
  4945
+            if (mState == EXECUTING && wasPaused) {
  4946
+                fillOutputBuffers();
  4947
+            }
  4948
+
  4949
+#if defined (NPA_BUFFERS)
  4950
+            if (mQuirks & OMXCodec::kThumbnailMode) {
  4951
+                if(mNumberOfNPABuffersSent){
  4952
+                    /*wait if atleast one filledbuffer is sent in NPA mode*/
  4953
+                    wait_status = (mNSecsToWait == 0) ? mBufferFilled.wait(mLock) : mBufferFilled.waitRelative(mLock, mNSecsToWait);
  4954
+                    if (wait_status) {
  4955
+                        LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
  4956
+                        return UNKNOWN_ERROR;
  4957
+                    }
  4958
+                }
  4959
+            }else{
  4960
+                //Dont wait forever.
  4961
+                wait_status = (mNSecsToWait == 0) ? mBufferFilled.wait(mLock) : mBufferFilled.waitRelative(mLock, mNSecsToWait);
  4962
+                if (wait_status) {
  4963
+                    LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
  4964
+                    return UNKNOWN_ERROR;
  4965
+                }
  4966
+            }
  4967
+#else
  4968
+            wait_status = (mNSecsToWait == 0) ? mBufferFilled.wait(mLock) : mBufferFilled.waitRelative(mLock, mNSecsToWait);
  4969
+            if (wait_status) {
  4970
+                LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
  4971
+                return UNKNOWN_ERROR;
  4972
+            }
  4973
+#endif
  4974
+        }
  4975
+        /*see if we received a port reconfiguration */
  4976
+        if (mState == RECONFIGURING) {
  4977
+            mOutputPortSettingsHaveChanged = false;
  4978
+            mFilledBuffers.clear();
  4979
+            return INFO_FORMAT_CHANGED;
  4980
+        }
  4981
+    }
  4982
+    else {
  4983
+        while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) {
  4984
+            wait_status = (mNSecsToWait == 0) ? mBufferFilled.wait(mLock) : mBufferFilled.waitRelative(mLock, mNSecsToWait);
3304 4985
         if (wait_status) {
3305 4986
             LOGE("Timed out waiting for the buffer! Line %d", __LINE__);
3306 4987
             return UNKNOWN_ERROR;
3307 4988
         }
3308 4989
     }
  4990
+    }
  4991
+
  4992
+#else
  4993
+    while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) {
  4994
+        mBufferFilled.wait(mLock);
  4995
+    }
  4996
+#endif
3309 4997
 
3310 4998
     if (mState == ERROR) {
3311 4999
         return UNKNOWN_ERROR;
... ...
@@ -3317,8 +5005,17 @@ status_t OMXCodec::read(
3317 5005
 
3318 5006
     if (mOutputPortSettingsHaveChanged) {
3319 5007
         mOutputPortSettingsHaveChanged = false;
3320  
-
  5008
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  5009
+        //for ducati codecs, to assert port reconfiguration immediately (so as to allocate overlay buffers upfront), we use mState as above.
  5010
+        //so, mOutputPortSettingsHaveChanged conditon check will result in redundant INFO_FORMAT_CHANGED event. Just proceed now.
  5011
+        //also, mOutputPortSettingsHaveChanged will be updated very late on port reenable, by the time overlay buffers are available and port enabled => just go ahead.
  5012
+        if (strcmp("OMX.TI.DUCATI1.VIDEO.DECODER", mComponentName)){
  5013
+            mFilledBuffers.clear();
  5014
+            return INFO_FORMAT_CHANGED;
  5015
+        }
  5016
+#else
3321 5017
         return INFO_FORMAT_CHANGED;
  5018
+#endif
3322 5019
     }
3323 5020
 
3324 5021
     size_t index = *mFilledBuffers.begin();
... ...
@@ -3326,6 +5023,9 @@ status_t OMXCodec::read(
3326 5023
 
3327 5024
     BufferInfo *info = &mPortBuffers[kPortIndexOutput].editItemAt(index);
3328 5025
     info->mMediaBuffer->add_ref();
  5026
+#ifdef OMAP_ENHANCEMENT
  5027
+    info->mOwnedByPlayer = true;
  5028
+#endif
3329 5029
     *buffer = info->mMediaBuffer;
3330 5030
 
3331 5031
     return OK;
... ...
@@ -3339,9 +5039,26 @@ void OMXCodec::signalBufferReturned(MediaBuffer *buffer) {
3339 5039
         BufferInfo *info = &buffers->editItemAt(i);
3340 5040
 
3341 5041
         if (info->mMediaBuffer == buffer) {
  5042
+#ifdef OMAP_ENHANCEMENT
  5043
+            info->mOwnedByPlayer = false;
  5044
+            if(mState == RECONFIGURING) {
  5045
+                return;
  5046
+            }
  5047
+#endif
3342 5048
             CHECK_EQ(mPortStatus[kPortIndexOutput], ENABLED);
3343  
-            fillOutputBuffer(info);
3344  
-            return;
  5049
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  5050
+            if (!(*buffers)[i].mOwnedByComponent) {
  5051
+                fillOutputBuffer(info);
  5052
+                return;
  5053
+            }
  5054
+            else {
  5055
+                CODEC_LOGV("OP BUFFER ALREADY OWNED BY COMPONENT. RETURNING");
  5056
+                return;
  5057
+            }
  5058
+#else
  5059
+        fillOutputBuffer(info);
  5060
+        return;
  5061
+#endif
3345 5062
         }
3346 5063
     }
3347 5064
 
... ...
@@ -3441,8 +5158,23 @@ static const char *videoCompressionFormatString(OMX_VIDEO_CODINGTYPE type) {
3441 5158
         "OMX_VIDEO_CodingRV",
3442 5159
         "OMX_VIDEO_CodingAVC",
3443 5160
         "OMX_VIDEO_CodingMJPEG",
  5161
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  5162
+        "OMX_VIDEO_CodingVP6",
  5163
+        "OMX_VIDEO_CodingVP7"
  5164
+#endif
3444 5165
     };
3445 5166
 
  5167
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  5168
+
  5169
+    if (type == (OMX_VIDEO_CODINGTYPE) OMX_VIDEO_CodingVP6) {
  5170
+        return kNames[9];
  5171
+    }
  5172
+
  5173
+    if (type == (OMX_VIDEO_CODINGTYPE) OMX_VIDEO_CodingVP7) {
  5174
+        return kNames[10];
  5175
+    }
  5176
+#endif
  5177
+
3446 5178
     size_t numNames = sizeof(kNames) / sizeof(kNames[0]);
3447 5179
 
3448 5180
     if (type < 0 || (size_t)type >= numNames) {
... ...
@@ -3744,8 +5476,26 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
3744 5476
                         (mQuirks & kDecoderLiesAboutNumberOfChannels)
3745 5477
                             ? numChannels : params.nChannels);
3746 5478
 
  5479
+#ifndef OMAP_ENHANCEMENT
3747 5480
                 // The codec-reported sampleRate is not reliable...
3748 5481
                 mOutputFormat->setInt32(kKeySampleRate, sampleRate);
  5482
+#else
  5483
+                if ((OMX_U32)sampleRate != params.nSamplingRate) {
  5484
+                    LOGW("Codec outputs a different number of samplerate than "
  5485
+                            "the input stream contains (contains %d samplerate, "
  5486
+                            "codec outputs %ld samplerate).",
  5487
+                            sampleRate, params.nSamplingRate);
  5488
+                    mOutputFormat->setInt32(
  5489
+                            kKeySampleRate,
  5490
+                            (mQuirks & kDecoderNeedsPortReconfiguration)
  5491
+                            ? params.nSamplingRate : sampleRate);
  5492
+                }
  5493
+                else
  5494
+                {
  5495
+                  // The codec-reported sampleRate is not reliable...
  5496
+                    mOutputFormat->setInt32(kKeySampleRate, sampleRate);
  5497
+                }
  5498
+#endif
3749 5499
             } else if (audio_def->eEncoding == OMX_AUDIO_CodingAMR) {
3750 5500
                 OMX_AUDIO_PARAM_AMRTYPE amr;
3751 5501
                 InitOMXParams(&amr);
... ...
@@ -3803,6 +5553,20 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
3803 5553
             } else if (video_def->eCompressionFormat == OMX_VIDEO_CodingAVC) {
3804 5554
                 mOutputFormat->setCString(
3805 5555
                         kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
  5556
+#if defined(OMAP_ENHANCEMENT)
  5557
+#if defined(TARGET_OMAP4)
  5558
+            } else if (video_def->eCompressionFormat == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP6) {
  5559
+                mOutputFormat->setCString(
  5560
+                        kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_VP6);
  5561
+            } else if (video_def->eCompressionFormat == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP7) {
  5562
+                mOutputFormat->setCString(
  5563
+                        kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_VP7);
  5564
+#endif
  5565
+            }
  5566
+            else if (video_def->eCompressionFormat == OMX_VIDEO_CodingWMV)
  5567
+            {
  5568
+                mOutputFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_WMV);
  5569
+#endif
3806 5570
             } else {
3807 5571
                 CHECK(!"Unknown compression format.");
3808 5572
             }
... ...
@@ -3860,6 +5624,37 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
3860 5624
             }
3861 5625
 
3862 5626
             mOutputFormat->setInt32(kKeyColorFormat, video_def->eColorFormat);
  5627
+
  5628
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  5629
+
  5630
+        /* for Non-Ducati HW codecs, padded with and height are updated with the
  5631
+        * video frame width and Height
  5632
+        */
  5633
+        mOutputFormat->setInt32(kKeyPaddedWidth, video_def->nFrameWidth);
  5634
+        mOutputFormat->setInt32(kKeyPaddedHeight, video_def->nFrameHeight);
  5635
+
  5636
+        /* Ducati codecs require padded output buffers.
  5637
+           Query proper size and update meta-data accordingly
  5638
+           which will be used later in renderer.
  5639
+           Note: 2D WxH in other OMX Get/Set parameter calls are seamless */
  5640
+        if (!strcmp("OMX.TI.DUCATI1.VIDEO.DECODER", mComponentName)) {
  5641
+
  5642
+            OMX_CONFIG_RECTTYPE tParamStruct;
  5643
+
  5644
+            InitOMXParams(&tParamStruct);
  5645
+            tParamStruct.nPortIndex = kPortIndexOutput;
  5646
+
  5647
+            err = mOMX->getParameter(
  5648
+                    mNode, (OMX_INDEXTYPE)OMX_TI_IndexParam2DBufferAllocDimension, &tParamStruct, sizeof(tParamStruct));
  5649
+
  5650
+            CHECK_EQ(err, OK);
  5651
+            mOutputFormat->setInt32(kKeyPaddedWidth, tParamStruct.nWidth);
  5652
+            mOutputFormat->setInt32(kKeyPaddedHeight, tParamStruct.nHeight);
  5653
+            LOGD("initOutputFormat WxH %dx%d Padded %dx%d ",
  5654
+                        (int) video_def->nFrameWidth, (int) video_def->nFrameHeight,
  5655
+                        (int) tParamStruct.nWidth, (int) tParamStruct.nHeight);
  5656
+        }
  5657
+#endif
3863 5658
             break;
3864 5659
         }
3865 5660
 
... ...
@@ -3879,6 +5674,23 @@ status_t OMXCodec::pause() {
3879 5674
     return OK;
3880 5675
 }
3881 5676
 
  5677
+#ifdef OMAP_ENHANCEMENT
  5678
+int OMXCodec::getNumofOutputBuffers() {
  5679
+    OMX_PARAM_PORTDEFINITIONTYPE def;
  5680
+    InitOMXParams(&def);
  5681
+    def.nPortIndex = kPortIndexOutput;
  5682
+
  5683
+    status_t err = mOMX->getParameter(
  5684
+            mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
  5685
+    CHECK_EQ(err, OK);
  5686
+    CHECK_EQ(def.eDomain, OMX_PortDomainVideo);
  5687
+
  5688
+    LOGD("CodecRecommended O/P BufferCnt[%ld]", def.nBufferCountActual);
  5689
+
  5690
+    return (def.nBufferCountActual);
  5691
+}
  5692
+#endif
  5693
+
3882 5694
 ////////////////////////////////////////////////////////////////////////////////
3883 5695
 
3884 5696
 status_t QueryCodecs(
Txt media/libstagefright/SampleTable.cpp
... ...
@@ -57,6 +57,11 @@ SampleTable::SampleTable(const sp<DataSource> &source)
57 57
       mNumSyncSamples(0),
58 58
       mSyncSamples(NULL),
59 59
       mLastSyncSampleIndex(0),
  60
+#ifdef OMAP_ENHANCEMENT
  61
+      mTimeToSampleCountCtts(0),
  62
+      mCttsSampleBuffer(NULL),
  63
+      mTimeToSampleCtts(NULL),
  64
+#endif
60 65
       mSampleToChunkEntries(NULL) {
61 66
     mSampleIterator = new SampleIterator(this);
62 67
 }
... ...
@@ -73,6 +78,15 @@ SampleTable::~SampleTable() {
73 78
 
74 79
     delete mSampleIterator;
75 80
     mSampleIterator = NULL;
  81
+
  82
+#ifdef OMAP_ENHANCEMENT
  83
+    delete[] mTimeToSampleCtts;
  84
+    mTimeToSampleCtts = NULL;
  85
+
  86
+    delete[] mCttsSampleBuffer;
  87
+    mCttsSampleBuffer = NULL;
  88
+#endif
  89
+
76 90
 }
77 91
 
78 92
 status_t SampleTable::setChunkOffsetParams(
... ...
@@ -227,6 +241,52 @@ status_t SampleTable::setSampleSizeParams(
227 241
     return OK;
228 242
 }
229 243
 
  244
+#ifdef OMAP_ENHANCEMENT
  245
+status_t SampleTable::setTimeToSampleParamsCtts(
  246
+        off_t data_offset, size_t data_size) {
  247
+    if (mTimeToSampleCtts != NULL || data_size < 8) {
  248
+        return ERROR_MALFORMED;
  249
+    }
  250
+    uint8_t header[8];
  251
+    uint32_t count_ctts,k=0;
  252
+    if (mDataSource->readAt(
  253
+                data_offset, header, sizeof(header)) < (ssize_t)sizeof(header)) {
  254
+        return ERROR_IO;
  255
+    }
  256
+
  257
+    if (U32_AT(header) != 0) {
  258
+        // Expected version = 0, flags = 0.
  259
+        return ERROR_MALFORMED;
  260
+    }
  261
+
  262
+    mTimeToSampleCountCtts = U32_AT(&header[4]);
  263
+
  264
+    //find out the actual number of samples
  265
+    mCttsSampleBuffer = new int32_t[mTimeToSampleCountCtts * 2];
  266
+    size_t size = sizeof(int32_t) * mTimeToSampleCountCtts * 2;
  267
+    if (mDataSource->readAt(
  268
+                data_offset + 8, mCttsSampleBuffer, size) < (ssize_t)size) {
  269
+        return ERROR_IO;
  270
+    }
  271
+
  272
+    uint32_t countsamples = 0;
  273
+    for(uint32_t i=0 ; i < mTimeToSampleCountCtts * 2; i+=2)
  274
+        countsamples += ntohl(mCttsSampleBuffer[i]);
  275
+
  276
+    mTimeToSampleCtts = new int32_t[countsamples];
  277
+
  278
+    for (uint32_t i = 0; i < mTimeToSampleCountCtts * 2; i++) {
  279
+        count_ctts = ntohl(mCttsSampleBuffer[i++]);
  280
+        for(uint32_t j = 0;j < count_ctts ;j++){
  281
+           mTimeToSampleCtts[k] = ntohl(mCttsSampleBuffer[i]);
  282
+           LOGV("for loop ctts samples %d %d %d",mTimeToSampleCountCtts,mTimeToSampleCtts[k],k);
  283
+           k++;
  284
+        }
  285
+    }
  286
+    return OK;
  287
+}
  288
+#endif
  289
+
230 290
 status_t SampleTable::setTimeToSampleParams(
231 291
         off_t data_offset, size_t data_size) {
232 292
     if (mTimeToSample != NULL || data_size < 8) {
... ...
@@ -421,7 +481,16 @@ status_t SampleTable::findSyncSampleNear(
421 481
     }
422 482
 
423 483
     --left;
  484
+#ifdef OMAP_ENHANCEMENT
  485
+    /*This variable will be initialized to 1, so in case the stss table
  486
+     *has 0 elements it will take by default frame 0. Frame 0 is supposed
  487
+     * to be an I frame every time. When stss is zero mNumSyncSamples
  488
+     * will be zero too, so the while loop will be skipped.
  489
+     * */
  490
+    uint32_t x=1;
  491
+#else
424 492
     uint32_t x;
  493
+#endif
425 494
     if (mDataSource->readAt(
426 495
                 mSyncSampleOffset + 8 + left * 4, &x, 4) != 4) {
427 496
         return ERROR_IO;
Txt media/libstagefright/StagefrightMediaScanner.cpp
... ...
@@ -43,6 +43,9 @@ static bool FileHasAcceptableExtension(const char *extension) {
43 43
         ".mpeg", ".ogg", ".mid", ".smf", ".imy", ".wma", ".aac",
44 44
         ".wav", ".amr", ".midi", ".xmf", ".rtttl", ".rtx", ".ota",
45 45
         ".mkv", ".mka", ".webm", ".ts", ".flac"
  46
+#if defined(OMAP_ENHANCEMENT)
  47
+        ,".wmv", ".asf"
  48
+#endif
46 49
     };
47 50
     static const size_t kNumValidExtensions =
48 51
         sizeof(kValidExtensions) / sizeof(kValidExtensions[0]);
Txt media/libstagefright/StagefrightMetadataRetriever.cpp
... ...
@@ -28,8 +28,16 @@
28 28
 #include <media/stagefright/MetaData.h>
29 29
 #include <media/stagefright/OMXCodec.h>
30 30
 
  31
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  32
+#include <OMX_TI_IVCommon.h>
  33
+#endif
  34
+
31 35
 namespace android {
32 36
 
  37
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  38
+extern void updateMetaData(sp<MetaData> meta_track);
  39
+#endif
  40
+
33 41
 StagefrightMetadataRetriever::StagefrightMetadataRetriever()
34 42
     : mParsedMetaData(false),
35 43
       mAlbumArt(NULL) {
... ...
@@ -49,7 +57,11 @@ StagefrightMetadataRetriever::~StagefrightMetadataRetriever() {
49 57
 }
50 58
 
51 59
 status_t StagefrightMetadataRetriever::setDataSource(const char *uri) {
  60
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  61
+    LOGD("setDataSource(%s)", uri);
  62
+#else
52 63
     LOGV("setDataSource(%s)", uri);
  64
+#endif
53 65
 
54 66
     mParsedMetaData = false;
55 67
     mMetaData.clear();
... ...
@@ -112,6 +124,24 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
112 124
         uint32_t flags,
113 125
         int64_t frameTimeUs,
114 126
         int seekMode) {
  127
+
  128
+#ifdef OMAP_ENHANCEMENT
  129
+    flags |= OMXCodec::kPreferThumbnailMode;
  130
+#ifdef TARGET_OMAP4
  131
+
  132
+    int32_t isInterlaced = false;
  133
+
  134
+    //Call config parser to update profile,level,interlaced,reference frame data
  135
+    updateMetaData(trackMeta);
  136
+
  137
+    trackMeta->findInt32(kKeyVideoInterlaced, &isInterlaced);
  138
+
  139
+    if(isInterlaced)
  140
+    {
  141
+      flags |= OMXCodec::kPreferInterlacedOutputContent;
  142
+    }
  143
+#endif
  144
+#endif
115 145
     sp<MediaSource> decoder =
116 146
         OMXCodec::Create(
117 147
                 client->interface(), source->getFormat(), false, source,
... ...
@@ -157,7 +187,18 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
157 187
             buffer->release();
158 188
             buffer = NULL;
159 189
         }
  190
+
160 191
         err = decoder->read(&buffer, &options);
  192
+#ifdef OMAP_ENHANCEMENT
  193
+        if(err == INFO_FORMAT_CHANGED)
  194
+        {
  195
+            int32_t w1,h1;
  196
+            decoder->getFormat()->findInt32(kKeyWidth, &w1);
  197
+            decoder->getFormat()->findInt32(kKeyHeight, &h1);
  198
+            LOGD("Got portreconfig event. New WxH %dx%d. wait 5mS for port to be enabled",w1,h1);
  199
+            usleep(5000); //sleep 5mS for port disable-enable to complete
  200
+        }
  201
+#endif
161 202
         options.clearSeekTo();
162 203
     } while (err == INFO_FORMAT_CHANGED
163 204
              || (buffer != NULL && buffer->range_length() == 0));
... ...
@@ -211,6 +252,77 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
211 252
     }
212 253
 
213 254
     VideoFrame *frame = new VideoFrame;
  255
+
  256
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  257
+    int32_t srcFormat;
  258
+    CHECK(meta->findInt32(kKeyColorFormat, &srcFormat));
  259
+
  260
+    int32_t format;
  261
+    const char *component;
  262
+
  263
+    //cache the display width and height
  264
+    int32_t displayWidth, displayHeight;
  265
+    displayWidth = width;
  266
+    displayHeight = height;
  267
+
  268
+    //update width & height with the buffer width&height
  269
+    if(!(meta->findInt32(kKeyPaddedWidth, &width))) {
  270
+        CHECK(meta->findInt32(kKeyWidth, &width));
  271
+    }
  272
+    if(!(meta->findInt32(kKeyPaddedHeight, &height))) {
  273
+        CHECK(meta->findInt32(kKeyHeight, &height));
  274
+    }
  275
+    LOGD("VideoFrame WxH %dx%d", displayWidth, displayHeight);
  276
+
  277
+    if(((OMX_COLOR_FORMATTYPE)srcFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) ||
  278
+       ((OMX_COLOR_FORMATTYPE)srcFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar_Sequential_TopBottom)){
  279
+        frame->mWidth = displayWidth;
  280
+        frame->mHeight = displayHeight;
  281
+        frame->mDisplayWidth = displayWidth;
  282
+        frame->mDisplayHeight = displayHeight;
  283
+        frame->mSize = displayWidth * displayHeight * 2;
  284
+        frame->mData = new uint8_t[frame->mSize];
  285
+    frame->mRotationAngle = rotationAngle;
  286
+    }else {
  287
+        frame->mWidth = width;
  288
+        frame->mHeight = height;
  289
+        frame->mDisplayWidth = width;
  290
+        frame->mDisplayHeight = height;
  291
+        frame->mSize = width * height * 2;
  292
+        frame->mData = new uint8_t[frame->mSize];
  293
+    frame->mRotationAngle = rotationAngle;
  294
+    }
  295
+
  296
+    if(((OMX_COLOR_FORMATTYPE)srcFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar) ||
  297
+       ((OMX_COLOR_FORMATTYPE)srcFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar_Sequential_TopBottom)){
  298
+
  299
+        ColorConverter converter(
  300
+                (OMX_COLOR_FORMATTYPE)srcFormat, OMX_COLOR_Format16bitRGB565);
  301
+
  302
+        CHECK(converter.isValid());
  303
+
  304
+        converter.convert(
  305
+                width, height,
  306
+                (const uint8_t *)buffer->data() + buffer->range_offset(),
  307
+                0, //1D buffer in 1.16 Ducati rls. If 2D buffer -> 4096 stride should be used
  308
+                frame->mData, displayWidth * 2,
  309
+                displayWidth,displayHeight,buffer->range_offset(),isInterlaced);
  310
+    }
  311
+    else{
  312
+
  313
+        ColorConverter converter(
  314
+                (OMX_COLOR_FORMATTYPE)srcFormat, OMX_COLOR_Format16bitRGB565);
  315
+
  316
+        CHECK(converter.isValid());
  317
+
  318
+        converter.convert(
  319
+                width, height,
  320
+                (const uint8_t *)buffer->data() + buffer->range_offset(),
  321
+                0,
  322
+                frame->mData, width * 2);
  323
+    }
  324
+
  325
+#else
214 326
     frame->mWidth = width;
215 327
     frame->mHeight = height;
216 328
     frame->mDisplayWidth = width;
... ...
@@ -231,6 +343,7 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
231 343
             (const uint8_t *)buffer->data() + buffer->range_offset(),
232 344
             0,
233 345
             frame->mData, width * 2);
  346
+#endif
234 347
 
235 348
     buffer->release();
236 349
     buffer = NULL;
Txt media/libstagefright/TISEIMessagesParser.cpp
... ...
@@ -0,0 +1,560 @@
  1
+/*
  2
+ * Copyright (C) Texas Instruments - http://www.ti.com/
  3
+ *
  4
+ * This library is free software; you can redistribute it and/or
  5
+ * modify it under the terms of the GNU Lesser General Public
  6
+ * License as published by the Free Software Foundation; either
  7
+ * version 2.1 of the License, or (at your option) any later version.
  8
+ *
  9
+ *
  10
+ * This library is distributed in the hope that it will be useful,
  11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13
+ * Lesser General Public License for more details.
  14
+ *
  15
+ *
  16
+ * You should have received a copy of the GNU Lesser General Public
  17
+ * License along with this library; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  19
+ */
  20
+
  21
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  22
+
  23
+#define LOG_TAG "SEI_TI_Parser"
  24
+#include "include/TISEIMessagesParser.h"
  25
+#include <utils/Log.h>
  26
+
  27
+#include <media/stagefright/MetaData.h>
  28
+#include <media/stagefright/MediaDebug.h>
  29
+#include <media/stagefright/Utils.h>
  30
+
  31
+#define MP4_INVALID_VOL_PARAM -1
  32
+#define STEREO_VIDEO_INFO_TYPE 0x15
  33
+#define FRAME_PACKING_ARRANGEMENT_TYPE 0x2D
  34
+// To account for payloadtype and payloadsize bytes
  35
+#define PAYLOAD_HEADER_SIZE 2
  36
+
  37
+#define PV_CLZ(A,B) while (((B) & 0x8000) == 0) {(B) <<=1; A++;}
  38
+
  39
+static const uint32_t mask[33] =
  40
+{
  41
+    0x00000000, 0x00000001, 0x00000003, 0x00000007,
  42
+    0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
  43
+    0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
  44
+    0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
  45
+    0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
  46
+    0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
  47
+    0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
  48
+    0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
  49
+    0xffffffff
  50
+};
  51
+
  52
+typedef struct
  53
+{
  54
+    uint8_t *data;
  55
+    uint32_t numBytes;
  56
+    uint32_t bytePos;
  57
+    uint32_t bitBuf;
  58
+    uint32_t dataBitPos;
  59
+    uint32_t  bitPos;
  60
+} mp4StreamType;
  61
+
  62
+/*------------------------------------------------------------------------------------
  63
+    sStereo_video_info
  64
+    This structure contains the stereo video information SEI msg elements
  65
+   -----------------------------------------------------------------------------------*/
  66
+typedef struct sei_stereo_video_info {
  67
+   uint32_t field_views_flag;                                                  //!< u(1)
  68
+   uint32_t top_field_is_left_view_flag;                                //!< u(1)
  69
+   uint32_t current_frame_is_left_view_flag;                       //!< u(1)
  70
+   uint32_t next_frame_is_second_view_flag;                     //!< u(1)
  71
+   uint32_t left_view_self_contained_flag;                           //!< u(1)
  72
+   uint32_t right_view_self_contained_flag;                         //!< u(1)
  73
+}sStereo_video_info;
  74
+
  75
+/*------------------------------------------------------------------------------------
  76
+    sframe_packing_arrangement
  77
+    This structure contains the frame packing arrangement info for SEI msg elements
  78
+   -----------------------------------------------------------------------------------*/
  79
+typedef struct sei_frame_packing_arrangement {
  80
+   uint32_t frame_packing_arrangement_id;                                                    //!< ue(v)
  81
+   uint32_t frame_packing_arrangement_cancel_flag;                                    //!< u(1)
  82
+   uint32_t frame_packing_arrangement_type;                                               //!< u(7)
  83
+   uint32_t quincunx_sampling_flag;                                                                //!< u(1)
  84
+   uint32_t content_interpretation_type;                                                          //!< u(6)
  85
+   uint32_t spatial_flipping_flag;                                                                      //!< u(1)
  86
+   uint32_t frame0_flipped_flag;                                                                      //!< u(1)
  87
+   uint32_t field_views_flag;                                                                             //!< u(1)
  88
+   uint32_t current_frame_is_frame0_flag;                                                     //!< u(7)
  89
+   uint32_t frame0_self_contained_flag;                                                         //!< u(1)
  90
+   uint32_t frame1_self_contained_flag;                                                         //!< u(1)
  91
+   uint32_t frame0_grid_position_x;                                                                //!< u(4)
  92
+   uint32_t frame0_grid_position_y;                                                                //!< u(4)
  93
+   uint32_t frame1_grid_position_x;                                                                //!< u(4)
  94
+   uint32_t frame1_grid_position_y;                                                                //!< u(4)
  95
+   uint32_t frame_packing_arrangement_reserved_byte;                             //!< u(8)
  96
+   uint32_t frame_packing_arrangement_repetition_period;                        //!< ue(v)
  97
+   uint32_t frame_packing_arrangement_extension_flag;                            //!< u(1)
  98
+}sframe_packing_arrangement;
  99
+
  100
+/*------------------------------------------------------------------------------------
  101
+    sframe_packing_arrangement_type
  102
+    This enum contains the frame packing arrangement type that will be passed to the display driver
  103
+   -----------------------------------------------------------------------------------*/
  104
+typedef enum {
  105
+   checkerboard = 0,
  106
+   column = 1,
  107
+   row = 2,
  108
+   side_by_side = 3,
  109
+   top_bottom = 4,
  110
+   temporal = 5,
  111
+}sframe_packing_arrangement_type;
  112
+
  113
+using namespace android;
  114
+
  115
+int16_t ShowBits(
  116
+    mp4StreamType *pStream,           /* Input Stream */
  117
+    uint8_t ucNBits,          /* nr of bits to read */
  118
+    uint32_t *pulOutData      /* output target */
  119
+)
  120
+{
  121
+    uint8_t *bits;
  122
+    uint32_t dataBitPos = pStream->dataBitPos;
  123
+    uint32_t bitPos = pStream->bitPos;
  124
+    uint32_t dataBytePos;
  125
+
  126
+    uint i;
  127
+
  128
+    if (ucNBits > (32 - bitPos))    /* not enough bits */
  129
+    {
  130
+        dataBytePos = dataBitPos >> 3; /* Byte Aligned Position */
  131
+        bitPos = dataBitPos & 7; /* update bit position */
  132
+        if (dataBytePos > pStream->numBytes - 4)
  133
+        {
  134
+            pStream->bitBuf = 0;
  135
+            for (i = 0;i < pStream->numBytes - dataBytePos;i++)
  136
+            {
  137
+                pStream->bitBuf |= pStream->data[dataBytePos+i];
  138
+                pStream->bitBuf <<= 8;
  139
+            }
  140
+            pStream->bitBuf <<= 8 * (3 - i);
  141
+        }
  142
+        else
  143
+        {
  144
+            bits = &pStream->data[dataBytePos];
  145
+            pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
  146
+        }
  147
+        pStream->bitPos = bitPos;
  148
+    }
  149
+
  150
+    bitPos += ucNBits;
  151
+
  152
+    *pulOutData = (pStream->bitBuf >> (32 - bitPos)) & mask[(uint16_t)ucNBits];
  153
+
  154
+    return 0;
  155
+}
  156
+
  157
+int16_t FlushBits(
  158
+    mp4StreamType *pStream,           /* Input Stream */
  159
+    uint8_t ucNBits                      /* number of bits to flush */
  160
+)
  161
+{
  162
+    uint8_t *bits;
  163
+    uint32_t dataBitPos = pStream->dataBitPos;
  164
+    uint32_t bitPos = pStream->bitPos;
  165
+    uint32_t dataBytePos;
  166
+
  167
+
  168
+    if ((dataBitPos + ucNBits) > (uint32_t)(pStream->numBytes << 3))
  169
+        return (-2); // Buffer over run
  170
+
  171
+    dataBitPos += ucNBits;
  172
+    bitPos     += ucNBits;
  173
+
  174
+    if (bitPos > 32)
  175
+    {
  176
+        dataBytePos = dataBitPos >> 3;    /* Byte Aligned Position */
  177
+        bitPos = dataBitPos & 7; /* update bit position */
  178
+        bits = &pStream->data[dataBytePos];
  179
+        pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
  180
+    }
  181
+
  182
+    pStream->dataBitPos = dataBitPos;
  183
+    pStream->bitPos     = bitPos;
  184
+
  185
+    return 0;
  186
+}
  187
+
  188
+int16_t ReadBits(
  189
+    mp4StreamType *pStream,           /* Input Stream */
  190
+    uint8_t ucNBits,                     /* nr of bits to read */
  191
+    uint32_t *pulOutData                 /* output target */
  192
+)
  193
+{
  194
+    uint8_t *bits;
  195
+    uint32_t dataBitPos = pStream->dataBitPos;
  196
+    uint32_t bitPos = pStream->bitPos;
  197
+    uint32_t dataBytePos;
  198
+
  199
+
  200
+    if ((dataBitPos + ucNBits) > (pStream->numBytes << 3))
  201
+    {
  202
+        *pulOutData = 0;
  203
+        return (-2); // Buffer over run
  204
+    }
  205
+
  206
+    //  dataBitPos += ucNBits;
  207
+
  208
+    if (ucNBits > (32 - bitPos))    /* not enough bits */
  209
+    {
  210
+        dataBytePos = dataBitPos >> 3;    /* Byte Aligned Position */
  211
+        bitPos = dataBitPos & 7; /* update bit position */
  212
+        bits = &pStream->data[dataBytePos];
  213
+        pStream->bitBuf = (bits[0] << 24) | (bits[1] << 16) | (bits[2] << 8) | bits[3];
  214
+    }
  215
+
  216
+    pStream->dataBitPos += ucNBits;
  217
+    pStream->bitPos      = (unsigned char)(bitPos + ucNBits);
  218
+
  219
+    *pulOutData = (pStream->bitBuf >> (32 - pStream->bitPos)) & mask[(uint16_t)ucNBits];
  220
+
  221
+    return 0;
  222
+}
  223
+
  224
+void ue_v(mp4StreamType *psBits, uint32_t *codeNum)
  225
+{
  226
+    uint32_t temp;
  227
+    uint tmp_cnt;
  228
+    int32_t leading_zeros = 0;
  229
+    ShowBits(psBits, 16, &temp);
  230
+    tmp_cnt = temp  | 0x1;
  231
+    PV_CLZ(leading_zeros, tmp_cnt)
  232
+
  233
+    if (leading_zeros < 8)
  234
+    {
  235
+        *codeNum = (temp >> (15 - (leading_zeros << 1))) - 1;
  236
+        FlushBits(psBits, (leading_zeros << 1) + 1);
  237
+    }
  238
+    else
  239
+    {
  240
+        ReadBits(psBits, (leading_zeros << 1) + 1, &temp);
  241
+        *codeNum = temp - 1;
  242
+    }
  243
+}
  244
+
  245
+/* Subclause D.1.22 */
  246
+int16_t stereo_video_info(mp4StreamType *psBits, S3D_params &mS3Dparams)
  247
+{
  248
+    // SEI message detected, default configuration
  249
+    mS3Dparams.active = true;
  250
+    mS3Dparams.mode = S3D_MODE_ON;
  251
+    mS3Dparams.fmt = S3D_FORMAT_OVERUNDER;
  252
+    mS3Dparams.subsampling = S3D_SS_NONE;
  253
+
  254
+    int16_t status =0;
  255
+    uint32_t temp;
  256
+    sStereo_video_info* pStereo_video_info = (sStereo_video_info *)malloc(sizeof(sStereo_video_info));
  257
+    ReadBits(psBits, 1, &temp);
  258
+    pStereo_video_info->field_views_flag = temp;
  259
+
  260
+    if( pStereo_video_info->field_views_flag )
  261
+    {
  262
+        mS3Dparams.metadata = S3D_SEI_STEREO_INFO_INTERLACED;
  263
+        ReadBits(psBits, 1, &temp);
  264
+        pStereo_video_info->top_field_is_left_view_flag = temp;
  265
+        if(pStereo_video_info->top_field_is_left_view_flag)
  266
+                mS3Dparams.order = S3D_ORDER_LF;
  267
+        else
  268
+                mS3Dparams.order = S3D_ORDER_RF;
  269
+    }
  270
+    else
  271
+    {
  272
+        mS3Dparams.metadata = S3D_SEI_STEREO_INFO_PROGRESSIVE;
  273
+        ReadBits(psBits, 1, &temp);
  274
+        pStereo_video_info->current_frame_is_left_view_flag = temp;
  275
+        if(pStereo_video_info->current_frame_is_left_view_flag)
  276
+                mS3Dparams.order = S3D_ORDER_LF;
  277
+        else
  278
+                mS3Dparams.order = S3D_ORDER_RF;
  279
+
  280
+        ReadBits(psBits, 1, &temp);
  281
+        pStereo_video_info->next_frame_is_second_view_flag = temp;
  282
+    }
  283
+
  284
+    ReadBits(psBits, 1, &temp);
  285
+    pStereo_video_info->left_view_self_contained_flag = temp;
  286
+    ReadBits(psBits, 1, &temp);
  287
+    pStereo_video_info->right_view_self_contained_flag = temp;
  288
+
  289
+    free(pStereo_video_info);
  290
+    return status;
  291
+}
  292
+
  293
+/* Subclause D.1.25 */
  294
+int16_t frame_packing_arrangement(mp4StreamType *psBits, S3D_params &mS3Dparams, int32_t payloadSize)
  295
+{
  296
+    // SEI message detected, default configuration
  297
+    mS3Dparams.active = true;
  298
+    mS3Dparams.mode = S3D_MODE_ON;
  299
+    mS3Dparams.subsampling = S3D_SS_NONE;
  300
+    mS3Dparams.metadata = S3D_SEI_STEREO_FRAME_PACKING;
  301
+
  302
+    int status =0, bitsToFlush = 0;
  303
+    uint32_t temp;
  304
+    uint32_t bitsread_diff = psBits->dataBitPos;
  305
+
  306
+    sframe_packing_arrangement* pframe_packing_arrangement = (sframe_packing_arrangement *)malloc(sizeof(sframe_packing_arrangement));
  307
+    // Get and pass frame_packing_arrangement_type
  308
+    ue_v(psBits, &(pframe_packing_arrangement->frame_packing_arrangement_id));
  309
+    ReadBits(psBits, 1, &temp);
  310
+    pframe_packing_arrangement->frame_packing_arrangement_cancel_flag = temp;
  311
+    if(!pframe_packing_arrangement->frame_packing_arrangement_cancel_flag)
  312
+    {
  313
+        ReadBits(psBits, 7, &temp);
  314
+        pframe_packing_arrangement->frame_packing_arrangement_type = temp;
  315
+        set_frame_packing_arrangement_type(pframe_packing_arrangement->frame_packing_arrangement_type, mS3Dparams.fmt, mS3Dparams.subsampling);
  316
+
  317
+        ReadBits(psBits, 1, &temp);
  318
+        pframe_packing_arrangement->quincunx_sampling_flag= temp;
  319
+        ReadBits(psBits, 6, &temp);
  320
+        pframe_packing_arrangement->content_interpretation_type= temp;
  321
+        if(pframe_packing_arrangement->content_interpretation_type)
  322
+            mS3Dparams.order = S3D_ORDER_LF;
  323
+        else
  324
+            mS3Dparams.order = S3D_ORDER_RF;
  325
+
  326
+        ReadBits(psBits, 1, &temp);
  327
+        pframe_packing_arrangement->spatial_flipping_flag= temp;
  328
+        ReadBits(psBits, 1, &temp);
  329
+        pframe_packing_arrangement->frame0_flipped_flag= temp;
  330
+        ReadBits(psBits, 1, &temp);
  331
+        pframe_packing_arrangement->field_views_flag= temp;
  332
+        ReadBits(psBits, 1, &temp);
  333
+        pframe_packing_arrangement->current_frame_is_frame0_flag = temp;
  334
+        ReadBits(psBits, 1, &temp);
  335
+        pframe_packing_arrangement->frame0_self_contained_flag= temp;
  336
+        ReadBits(psBits, 1, &temp);
  337
+        pframe_packing_arrangement->frame1_self_contained_flag= temp;
  338
+
  339
+        if(!pframe_packing_arrangement->quincunx_sampling_flag &&
  340
+            pframe_packing_arrangement->content_interpretation_type != temporal)
  341
+        {
  342
+            ReadBits(psBits, 4, &temp);
  343
+            pframe_packing_arrangement->frame0_grid_position_x= temp;
  344
+            ReadBits(psBits, 4, &temp);
  345
+            pframe_packing_arrangement->frame0_grid_position_y = temp;
  346
+            ReadBits(psBits, 4, &temp);
  347
+            pframe_packing_arrangement->frame1_grid_position_x= temp;
  348
+            ReadBits(psBits, 4, &temp);
  349
+            pframe_packing_arrangement->frame1_grid_position_y= temp;
  350
+        }
  351
+        ReadBits(psBits, 8, &temp);
  352
+        pframe_packing_arrangement->frame_packing_arrangement_reserved_byte = temp;
  353
+        ue_v(psBits, &(pframe_packing_arrangement->frame_packing_arrangement_repetition_period));
  354
+    }
  355
+
  356
+    ReadBits(psBits, 1, &temp);
  357
+    pframe_packing_arrangement->frame_packing_arrangement_extension_flag = temp;
  358
+
  359
+    // To account for trailling 0;
  360
+    bitsread_diff= psBits->dataBitPos - bitsread_diff;
  361
+    bitsToFlush = 8*payloadSize - bitsread_diff;
  362
+    if(bitsToFlush > 0)
  363
+        FlushBits(psBits, bitsToFlush);
  364
+
  365
+    free(pframe_packing_arrangement);
  366
+    return status; // return 0 for success
  367
+}
  368
+
  369
+// Annex D.1 SEI payload syntax
  370
+int16_t sei_payload(mp4StreamType *psBits, int32_t payloadType, int32_t payloadSize, S3D_params &mS3Dparams)
  371
+{
  372
+    int16_t status = 0;
  373
+    int i;
  374
+    switch (payloadType)
  375
+    {
  376
+        case STEREO_VIDEO_INFO_TYPE:
  377
+        /*     Stereo video Information SEI message          */
  378
+            status = stereo_video_info(psBits, mS3Dparams);
  379
+        break;
  380
+        case FRAME_PACKING_ARRANGEMENT_TYPE:
  381
+        /*      Frame packaging arrangement SEI message */
  382
+            status = frame_packing_arrangement(psBits, mS3Dparams, payloadSize);
  383
+        break;
  384
+        default: //for case 0-20,22-44 and reserved sei messages
  385
+        /* SEI messages reserved or not supported*/
  386
+        LOGE("SEI messages reserved or not supported: 0x%x\n", payloadType);
  387
+        for (i = 0; i < payloadSize; i++)
  388
+        {
  389
+            FlushBits(psBits, 8);
  390
+        }
  391
+        break;
  392
+    }
  393
+    return status; // return 0 for success
  394
+}
  395
+
  396
+//ref subclause 7.3.2.3.1 SEI message syntax
  397
+int16_t sei_message(mp4StreamType *psBits, /*int32_t *ff_byte, */ int32_t *last_payload_type_byte, int32_t *last_payload_size_byte, S3D_params &mS3Dparams)
  398
+{
  399
+    uint32_t temp;
  400
+    int32_t payloadType, payloadSize;
  401
+    int16_t status = 0;
  402
+
  403
+    payloadType = 0;
  404
+    // Not needed as the output of the read function does not contain the
  405
+    // emulation prevention bytes.
  406
+    /*while(0xFF == ReadBits(psBits, 8, &temp)) {
  407
+        *ff_byte = temp;
  408
+        payloadType += 255;
  409
+    }*/
  410
+
  411
+    ReadBits(psBits, 8, &temp);
  412
+    *last_payload_type_byte = temp;
  413
+    payloadType += *last_payload_type_byte;
  414
+    LOGV("Value for payloadType = %d \n", payloadType);
  415
+
  416
+    payloadSize = 0;
  417
+    // Not needed as the output of the read function does not contain the
  418
+    // emulation prevention bytes.
  419
+    /*while(0xFF == ReadBits(psBits, 8, &temp)) {
  420
+        *ff_byte = temp;
  421
+        payloadSize += 255;
  422
+    }*/
  423
+
  424
+    ReadBits(psBits, 8, &temp);
  425
+    *last_payload_size_byte = temp;
  426
+    payloadSize += *last_payload_size_byte;
  427
+    LOGV("Value for payloadSize = %d \n", payloadSize);
  428
+
  429
+    status = sei_payload(psBits, payloadType, payloadSize, mS3Dparams);
  430
+
  431
+    return status;
  432
+}
  433
+
  434
+namespace android {
  435
+
  436
+static int got_packing = 0;
  437
+/* ======================================================================== */
  438
+/*  Function : sei_rbsp()                                                   */
  439
+/*  Purpose  : parse SEI messages NAL unit (ref: subclause 7.3.2.3)         */
  440
+/* ======================================================================== */
  441
+int16_t sei_rbsp(uint8_t *buffer, int32_t length , S3D_params &mS3Dparams)
  442
+{
  443
+    int16_t status = 0;
  444
+    int32_t last_payload_type_byte, last_payload_size_byte;
  445
+    uint32_t temp;
  446
+    int32_t NALSize = 0;
  447
+
  448
+    got_packing = 0;
  449
+    mp4StreamType psBits;
  450
+    psBits.data  = buffer;
  451
+    psBits.numBytes = length;
  452
+    psBits.bytePos = 0;
  453
+    psBits.bitBuf = 0;
  454
+    psBits.dataBitPos = 0;
  455
+    psBits.bitPos = 32;
  456
+
  457
+    // Check if SEI NAL Unit
  458
+    ReadBits(&psBits, 8, &temp);
  459
+    if ((temp & 0x1F) != 6) return MP4_INVALID_VOL_PARAM;
  460
+
  461
+    //Account for NAL Unit type message
  462
+    NALSize++;
  463
+
  464
+  /*---------------------------------------------------------------------------
  465
+  *     Multiple SEI messages can be present in one SEI NAL. This do-while
  466
+  *     loop processes one SEI message per iteration.
  467
+  ----------------------------------------------------------------------------*/
  468
+    do
  469
+    {
  470
+        status = 0;
  471
+        if (!got_packing) {
  472
+            status = sei_message(&psBits, &last_payload_type_byte, &last_payload_size_byte, mS3Dparams);
  473
+        }
  474
+        ShowBits(&psBits, 8, &temp);
  475
+        NALSize += PAYLOAD_HEADER_SIZE + last_payload_size_byte;
  476
+    }while(temp != 0x80 && NALSize < (length-1) ); // more_rbsp_data();  We do account for termination bit 0x80
  477
+  // ignore the trailing bits rbsp_trailing_bits();
  478
+  //assert( NALSize+1 == length );
  479
+
  480
+    return status;
  481
+}
  482
+
  483
+/* ======================================================================== */
  484
+/*  Function : AVCGetNALType()                                              */
  485
+/*  Purpose  : Sniff NAL type from the bitstream                            */
  486
+/* ======================================================================== */
  487
+int32_t AVCGetNALType(uint8_t *bitstream, int size,int *nal_type, int *nal_ref_idc)
  488
+{
  489
+    int forbidden_zero_bit;
  490
+    if (size > 0)
  491
+    {
  492
+        forbidden_zero_bit = bitstream[0] >> 7;
  493
+        if (forbidden_zero_bit != 0)
  494
+            return -1;
  495
+        *nal_ref_idc = (bitstream[0] & 0x60) >> 5;
  496
+        *nal_type = bitstream[0] & 0x1F;
  497
+        return 0;
  498
+    }
  499
+
  500
+    return -1;
  501
+}
  502
+
  503
+void set_frame_packing_arrangement_type(uint32_t frame_packing_arrangement_type, uint32_t &format, uint32_t &subsampling)
  504
+{
  505
+
  506
+    switch(frame_packing_arrangement_type)
  507
+    {
  508
+        case checkerboard:
  509
+        {
  510
+            LOGV("Frame packing: Checkerboard \n");
  511
+            format = S3D_FORMAT_CHECKB;
  512
+            break;
  513
+        }
  514
+        case column:
  515
+        {
  516
+            LOGV("Frame packing: col il \n");
  517
+            format = S3D_FORMAT_COL_IL;
  518
+            break;
  519
+        }
  520
+        case row:
  521
+        {
  522
+            LOGV("Frame packing: row il \n");
  523
+            format = S3D_FORMAT_ROW_IL;
  524
+            break;
  525
+        }
  526
+        case side_by_side:
  527
+        {
  528
+            LOGV("Frame packing: side_by_side \n");
  529
+            format = S3D_FORMAT_SIDEBYSIDE;
  530
+            subsampling = S3D_SS_HOR;
  531
+            break;
  532
+        }
  533
+        case top_bottom:
  534
+        {
  535
+            LOGV("Frame packing: TOP/BOT \n");
  536
+            format = S3D_FORMAT_OVERUNDER;
  537
+            subsampling = S3D_SS_VERT;
  538
+            break;
  539
+        }
  540
+        case temporal:
  541
+        {
  542
+            LOGV("Frame packing: Frame Seq \n");
  543
+            format = S3D_FORMAT_FRM_SEQ;
  544
+            break;
  545
+        }
  546
+        default:
  547
+        {
  548
+            LOGV("Frame packing: Default to top/bottom \n");
  549
+            format = S3D_FORMAT_OVERUNDER;
  550
+            break;
  551
+        }
  552
+    }
  553
+    got_packing = 1;
  554
+}
  555
+
  556
+}// namespace android
  557
+
  558
+
  559
+#endif
  560
+
Txt media/libstagefright/TIVideoConfigParser.cpp
... ...
@@ -0,0 +1,596 @@
  1
+/*
  2
+ * Copyright (C) Texas Instruments - http://www.ti.com/
  3
+ *
  4
+ * This library is free software; you can redistribute it and/or
  5
+ * modify it under the terms of the GNU Lesser General Public
  6
+ * License as published by the Free Software Foundation; either
  7
+ * version 2.1 of the License, or (at your option) any later version.
  8
+ *
  9
+ *
  10
+ * This library is distributed in the hope that it will be useful,
  11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13
+ * Lesser General Public License for more details.
  14
+ *
  15
+ *
  16
+ * You should have received a copy of the GNU Lesser General Public
  17
+ * License along with this library; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  19
+ */
  20
+
  21
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  22
+
  23
+#define LOG_TAG "SF_TI_Parser"
  24
+#include <utils/Log.h>
  25
+//#define LOG_NDEBUG 0
  26
+
  27
+#include <media/stagefright/MetaData.h>
  28
+#include <media/stagefright/MediaDebug.h>
  29
+#include <media/stagefright/Utils.h>
  30
+
  31
+#define MP4_INVALID_VOL_PARAM               -1
  32
+#define SHORT_HEADER_MODE                   -4
  33
+
  34
+#define VISUAL_OBJECT_SEQUENCE_START_CODE   0x01B0
  35
+#define VISUAL_OBJECT_SEQUENCE_END_CODE     0x01B1
  36
+#define VISUAL_OBJECT_START_CODE            0x01B5
  37
+#define VO_START_CODE                       0x8
  38
+#define VO_HEADER_LENGTH                    32
  39
+#define VOL_START_CODE                      0x12
  40
+#define VOL_START_CODE_LENGTH               28
  41
+
  42
+#define GROUP_START_CODE                    0x01B3
  43
+#define GROUP_START_CODE_LENGTH             32
  44
+
  45
+#define VOP_ID_CODE_LENGTH                  5
  46
+#define VOP_TEMP_REF_CODE_LENGTH            16
  47
+
  48
+#define USER_DATA_START_CODE                0x01B2
  49
+#define USER_DATA_START_CODE_LENGTH         32
  50
+
  51
+#define SHORT_VIDEO_START_MARKER            0x20
  52
+#define SHORT_VIDEO_START_MARKER_LENGTH     22
  53
+
  54
+
  55
+namespace android {
  56
+
  57
+
  58
+typedef struct __bit_buffer {
  59
+    uint8_t * start;
  60
+    size_t size;
  61
+    uint8_t * current;
  62
+    uint8_t read_bits;
  63
+} bit_buffer;
  64
+
  65
+static void skip_bits(bit_buffer * bb, size_t nbits) {
  66
+    bb->current = bb->current + ((nbits + bb->read_bits) / 8);
  67
+    bb->read_bits = (uint8_t)((bb->read_bits + nbits) % 8);
  68
+}
  69
+
  70
+static uint8_t get_bit(bit_buffer * bb) {
  71
+    uint8_t ret;
  72
+    ret = (*(bb->current) >> (7 - bb->read_bits)) & 0x1;
  73
+    if (bb->read_bits == 7) {
  74
+        bb->read_bits = 0;
  75
+        bb->current++;
  76
+    }
  77
+    else {
  78
+        bb->read_bits++;
  79
+    }
  80
+    return ret;
  81
+}
  82
+
  83
+static uint32_t get_bits(bit_buffer * bb, size_t nbits) {
  84
+    uint32_t i, ret;
  85
+    ret = 0;
  86
+    for (i = 0; i < nbits; i++) {
  87
+        ret = (ret << 1) + get_bit(bb);
  88
+    }
  89
+    return ret;
  90
+}
  91
+
  92
+static uint32_t exp_golomb_ue(bit_buffer * bb) {
  93
+    uint8_t bit, significant_bits;
  94
+    significant_bits = 0;
  95
+    bit = get_bit(bb);
  96
+    while (bit == 0) {
  97
+        significant_bits++;
  98
+        bit = get_bit(bb);
  99
+    }
  100
+    return (1 << significant_bits) + get_bits(bb, significant_bits) - 1;
  101
+}
  102
+
  103
+static int32_t exp_golomb_se(bit_buffer * bb) {
  104
+    int32_t ret;
  105
+    ret = exp_golomb_ue(bb);
  106
+    if ((ret & 0x1) == 0) {
  107
+        return -(ret >> 1);
  108
+    }
  109
+    else {
  110
+        return (ret + 1) >> 1;
  111
+    }
  112
+}
  113
+
  114
+static void parse_scaling_list(uint32_t size, bit_buffer * bb) {
  115
+    uint32_t last_scale, next_scale, i;
  116
+    int32_t delta_scale;
  117
+    last_scale = 8;
  118
+    next_scale = 8;
  119
+    for (i = 0; i < size; i++) {
  120
+        if (next_scale != 0) {
  121
+            delta_scale = exp_golomb_se(bb);
  122
+            next_scale = (last_scale + delta_scale + 256) % 256;
  123
+        }
  124
+        if (next_scale != 0) {
  125
+            last_scale = next_scale;
  126
+        }
  127
+    }
  128
+}
  129
+
  130
+void parse_sps(uint8_t * sps,size_t sps_size,uint8_t *aprofile,uint8_t *alevel,uint32_t *num_ref_frames,uint8_t *interlaced)
  131
+{
  132
+    bit_buffer bb;
  133
+    uint32_t pic_order_cnt_type, width_in_mbs, height_in_map_units;
  134
+    uint32_t i, size, left, right, top, bottom;
  135
+    uint8_t frame_mbs_only_flag;
  136
+    uint8_t profile, level;
  137
+    uint32_t width,height;
  138
+
  139
+    bb.start = sps;
  140
+    bb.size = sps_size;
  141
+    bb.current = sps;
  142
+    bb.read_bits = 0;
  143
+
  144
+    /* skip first byte, since we already know we're parsing a SPS */
  145
+    skip_bits(&bb, 8);
  146
+
  147
+    /* get profile */
  148
+    profile = (uint8_t) get_bits(&bb, 8);
  149
+    LOGV("AVC Profile %d",profile);
  150
+
  151
+    /* skip 8 bits */
  152
+    skip_bits(&bb, 8);
  153
+
  154
+    /* get level */
  155
+    level = (uint8_t) get_bits(&bb, 8);
  156
+    LOGV("AVC Level %d",level);
  157
+
  158
+    *aprofile = profile;
  159
+    *alevel = level;
  160
+
  161
+    /* read sps id, first exp-golomb encoded value */
  162
+    exp_golomb_ue(&bb);
  163
+
  164
+    if (profile == 100 || profile == 110 || profile == 122 || profile == 144) {
  165
+        /* chroma format idx */
  166
+        if (exp_golomb_ue(&bb) == 3) {
  167
+            skip_bits(&bb, 1);
  168
+        }
  169
+        /* bit depth luma minus8 */
  170
+        exp_golomb_ue(&bb);
  171
+        /* bit depth chroma minus8 */
  172
+        exp_golomb_ue(&bb);
  173
+        /* Qpprime Y Zero Transform Bypass flag */
  174
+        skip_bits(&bb, 1);
  175
+        /* Seq Scaling Matrix Present Flag */
  176
+        if (get_bit(&bb)) {
  177
+            for (i = 0; i < 8; i++) {
  178
+                /* Seq Scaling List Present Flag */
  179
+                if (get_bit(&bb)) {
  180
+                    parse_scaling_list(i < 6 ? 16 : 64, &bb);
  181
+                }
  182
+            }
  183
+        }
  184
+    }
  185
+    /* log2_max_frame_num_minus4 */
  186
+    exp_golomb_ue(&bb);
  187
+    /* pic_order_cnt_type */
  188
+    pic_order_cnt_type = exp_golomb_ue(&bb);
  189
+    if (pic_order_cnt_type == 0) {
  190
+        /* log2_max_pic_order_cnt_lsb_minus4 */
  191
+        exp_golomb_ue(&bb);
  192
+    }
  193
+    else if (pic_order_cnt_type == 1) {
  194
+        /* delta_pic_order_always_zero_flag */
  195
+        skip_bits(&bb, 1);
  196
+        /* offset_for_non_ref_pic */
  197
+        exp_golomb_se(&bb);
  198
+        /* offset_for_top_to_bottom_field */
  199
+        exp_golomb_se(&bb);
  200
+        size = exp_golomb_ue(&bb);
  201
+        for (i = 0; i < size; i++) {
  202
+            /* offset_for_ref_frame */
  203
+            exp_golomb_se(&bb);
  204
+        }
  205
+    }
  206
+
  207
+    /* num_ref_frames */
  208
+    *num_ref_frames = exp_golomb_ue(&bb);
  209
+    LOGV("AVC No of Ref frames %d",*num_ref_frames);
  210
+
  211
+    /* gaps_in_frame_num_value_allowed_flag */
  212
+    skip_bits(&bb, 1);
  213
+    /* pic_width_in_mbs */
  214
+    width_in_mbs = exp_golomb_ue(&bb) + 1;
  215
+    /* pic_height_in_map_units */
  216
+    height_in_map_units = exp_golomb_ue(&bb) + 1;
  217
+    /* frame_mbs_only_flag */
  218
+    frame_mbs_only_flag = get_bit(&bb);
  219
+
  220
+    LOGV("AVC frame_mbs_only_flag %d", frame_mbs_only_flag);
  221
+
  222
+    /* 0-interlaced. 1-progressive */
  223
+    *interlaced = !frame_mbs_only_flag;
  224
+
  225
+    if (!frame_mbs_only_flag) {
  226
+        /* mb_adaptive_frame_field */
  227
+        skip_bits(&bb, 1);
  228
+    }
  229
+    /* direct_8x8_inference_flag */
  230
+    skip_bits(&bb, 1);
  231
+    /* frame_cropping */
  232
+    left = right = top = bottom = 0;
  233
+    if (get_bit(&bb)) {
  234
+        left = exp_golomb_ue(&bb) * 2;
  235
+        right = exp_golomb_ue(&bb) * 2;
  236
+        top = exp_golomb_ue(&bb) * 2;
  237
+        bottom = exp_golomb_ue(&bb) * 2;
  238
+        if (!frame_mbs_only_flag) {
  239
+            top *= 2;
  240
+            bottom *= 2;
  241
+        }
  242
+    }
  243
+
  244
+    /* width */
  245
+    width = width_in_mbs * 16 - (left + right);
  246
+    /* height */
  247
+    height = height_in_map_units * 16 - (top + bottom);
  248
+    if (!frame_mbs_only_flag) {
  249
+        height *= 2;
  250
+    }
  251
+}
  252
+
  253
+
  254
+void ReadBits(bit_buffer *bb, int nbits, uint32_t* val)
  255
+{
  256
+    *val = get_bits(bb, nbits);
  257
+}
  258
+
  259
+int16_t Search4VOLHeader(bit_buffer *psBits)
  260
+{
  261
+    uint32_t i;
  262
+    int32_t count = 0;
  263
+    int16_t status = -1;
  264
+
  265
+    uint32_t curr_state = 0;
  266
+    bool found = false;
  267
+
  268
+     /* search 0x00 0x00 0x01 0x20 */
  269
+
  270
+     /* Byte alignment*/
  271
+     while(psBits->read_bits)
  272
+     {
  273
+         ReadBits(psBits,1,&i);
  274
+     }
  275
+
  276
+     do{
  277
+        ReadBits(psBits,8,&i);
  278
+        switch(curr_state)
  279
+        {
  280
+            case 0:
  281
+                      if(i==0) curr_state = 1;      /* just got 00 */
  282
+                          else curr_state = 0;
  283
+                      break;
  284
+            case 1:
  285
+                      if(i==0) curr_state = 2;      /* Now 00. Got 00*/
  286
+                      else curr_state = 0;
  287
+                      break;
  288
+            case 2:
  289
+                      if(i==1) curr_state = 3;      /* Now 01. Got 00 00 */
  290
+                      else if(i==0) curr_state = 2; /* Now 00. Got 00 00*/
  291
+                      else curr_state = 0;
  292
+                      break;
  293
+            case 3:
  294
+                      if(i==0x20) found = true;     /*Now 20. Got 00 00 01*/
  295
+                      else curr_state = 0;
  296
+                      break;
  297
+        };
  298
+
  299
+     }while((psBits->current < psBits->start + psBits->size)  && !found);
  300
+
  301
+     if(found)
  302
+       status = 0;
  303
+     else
  304
+       status = -1;
  305
+
  306
+    return status;
  307
+}
  308
+
  309
+int16_t parse_vol(uint8_t *vol,size_t vol_size,uint8_t *aprofile,uint8_t *alevel,uint32_t *num_ref_frames,uint8_t* interlaced)
  310
+{
  311
+    int16_t iErrorStat;
  312
+    uint32_t codeword;
  313
+    uint32_t time_increment_resolution, nbits_time_increment;
  314
+    uint32_t i, j;
  315
+
  316
+    uint32_t display_width, display_height;
  317
+    uint32_t width,height;
  318
+
  319
+    int32_t* profilelevel;
  320
+
  321
+
  322
+    bit_buffer bb;
  323
+    bb.start = vol;
  324
+    bb.size = vol_size;
  325
+    bb.current = vol;
  326
+    bb.read_bits = 0;
  327
+
  328
+    bit_buffer *psBits = &bb;
  329
+
  330
+    uint32_t status =  0;
  331
+
  332
+    while(psBits->current <(psBits->start + psBits->size)){
  333
+
  334
+    /* detect VOL start code 00 00 01 20 */
  335
+    uint32_t status = Search4VOLHeader(psBits);
  336
+
  337
+        uint32_t vol_id;
  338
+
  339
+        /* vol_id (4 bits) */
  340
+        //ReadBits(psBits, 4, & vol_id);
  341
+
  342
+        // RandomAccessibleVOLFlag
  343
+        ReadBits(psBits, 1, &codeword);
  344
+
  345
+        //Video Object Type Indication
  346
+        ReadBits(psBits, 8, &codeword);
  347
+        if (codeword != 1)
  348
+        {
  349
+            //return MP4_INVALID_VOL_PARAM; //TI supports this feature
  350
+        }
  351
+
  352
+        // is_object_layer_identifier
  353
+        ReadBits(psBits, 1, &codeword);
  354
+
  355
+        if (codeword)
  356
+        {
  357
+            ReadBits(psBits, 4, &codeword);
  358
+            ReadBits(psBits, 3, &codeword);
  359
+        }
  360
+
  361
+        // aspect ratio
  362
+        ReadBits(psBits, 4, &codeword);
  363
+
  364
+        if (codeword == 0xF)
  365
+        {
  366
+            // Extended Parameter
  367
+            /* width */
  368
+            ReadBits(psBits, 8, &codeword);
  369
+            /* height */
  370
+            ReadBits(psBits, 8, &codeword);
  371
+        }
  372
+
  373
+        ReadBits(psBits, 1, &codeword);
  374
+
  375
+        if (codeword)
  376
+        {
  377
+            ReadBits(psBits, 2, &codeword);
  378
+            if (codeword != 1)
  379
+            {
  380
+                return MP4_INVALID_VOL_PARAM;
  381
+            }
  382
+
  383
+            ReadBits(psBits, 1, &codeword);
  384
+
  385
+            if (!codeword)
  386
+            {
  387
+                //return MP4_INVALID_VOL_PARAM; //TI supports this feature
  388
+            }
  389
+
  390
+            ReadBits(psBits, 1, &codeword);
  391
+            if (codeword)   /* if (vbv_parameters) {}, page 36 */
  392
+            {
  393
+                ReadBits(psBits, 15, &codeword);
  394
+                ReadBits(psBits, 1, &codeword);
  395
+                if (codeword != 1)
  396
+                {
  397
+                    return MP4_INVALID_VOL_PARAM;
  398
+                }
  399
+
  400
+                ReadBits(psBits, 15, &codeword);
  401
+                ReadBits(psBits, 1, &codeword);
  402
+                if (codeword != 1)
  403
+                {
  404
+                    return MP4_INVALID_VOL_PARAM;
  405
+                }
  406
+
  407
+
  408
+                ReadBits(psBits, 19, &codeword);
  409
+                if (!(codeword & 0x8))
  410
+                {
  411
+                    return MP4_INVALID_VOL_PARAM;
  412
+                }
  413
+
  414
+                ReadBits(psBits, 11, &codeword);
  415
+                ReadBits(psBits, 1, &codeword);
  416
+                if (codeword != 1)
  417
+                {
  418
+                    return MP4_INVALID_VOL_PARAM;
  419
+                }
  420
+
  421
+                ReadBits(psBits, 15, &codeword);
  422
+                ReadBits(psBits, 1, &codeword);
  423
+                if (codeword != 1)
  424
+                {
  425
+                    return MP4_INVALID_VOL_PARAM;
  426
+                }
  427
+            }
  428
+
  429
+        }
  430
+
  431
+        ReadBits(psBits, 2, &codeword);
  432
+
  433
+        if (codeword != 0)
  434
+        {
  435
+            return MP4_INVALID_VOL_PARAM;
  436
+        }
  437
+
  438
+        ReadBits(psBits, 1, &codeword);
  439
+        if (codeword != 1)
  440
+        {
  441
+            return MP4_INVALID_VOL_PARAM;
  442
+        }
  443
+
  444
+        ReadBits(psBits, 16, &codeword);
  445
+        time_increment_resolution = codeword;
  446
+
  447
+
  448
+        ReadBits(psBits, 1, &codeword);
  449
+        if (codeword != 1)
  450
+        {
  451
+            return MP4_INVALID_VOL_PARAM;
  452
+        }
  453
+
  454
+
  455
+
  456
+        ReadBits(psBits, 1, &codeword);
  457
+
  458
+        if (codeword && time_increment_resolution > 2)
  459
+        {
  460
+            i = time_increment_resolution - 1;
  461
+            j = 1;
  462
+            while (i >>= 1)
  463
+            {
  464
+                j++;
  465
+            }
  466
+            nbits_time_increment = j;
  467
+
  468
+            ReadBits(psBits, nbits_time_increment, &codeword);
  469
+        }
  470
+
  471
+        ReadBits(psBits, 1, &codeword);
  472
+        if (codeword != 1)
  473
+        {
  474
+            return MP4_INVALID_VOL_PARAM;
  475
+        }
  476
+
  477
+        /* this should be 176 for QCIF */
  478
+        ReadBits(psBits, 13, &codeword);
  479
+        display_width = (uint32_t)codeword;
  480
+        ReadBits(psBits, 1, &codeword);
  481
+        if (codeword != 1)
  482
+        {
  483
+            return MP4_INVALID_VOL_PARAM;
  484
+        }
  485
+
  486
+        /* this should be 144 for QCIF */
  487
+        ReadBits(psBits, 13, &codeword);
  488
+        display_height = (uint32_t)codeword;
  489
+
  490
+        width = (display_width + 15) & -16;
  491
+        height = (display_height + 15) & -16;
  492
+
  493
+        /* marker */
  494
+        ReadBits(psBits, 1, &codeword);
  495
+
  496
+        /* interlaced */
  497
+        ReadBits(psBits, 1, &codeword);
  498
+        LOGD("INTERLACE 0x%x",codeword);
  499
+
  500
+        if(codeword == 1)
  501
+        {
  502
+            *interlaced = (uint8_t) 1;
  503
+        }
  504
+        else
  505
+        {
  506
+            *interlaced = (uint8_t) 0;
  507
+        }
  508
+        return 0;
  509
+
  510
+    }
  511
+
  512
+    return 0;
  513
+}
  514
+
  515
+void updateMetaData(sp<MetaData> meta_track)
  516
+{
  517
+    uint32_t type;
  518
+    const void *data;
  519
+    size_t size;
  520
+
  521
+    uint8_t profile,level,interlaced;
  522
+    uint32_t num_ref_frames;
  523
+
  524
+    interlaced = 0;
  525
+    profile = 0;
  526
+    level = 0;
  527
+    num_ref_frames = 0;
  528
+
  529
+    if ( meta_track->findData(kKeyESDS, &type, &data, &size)) {
  530
+        LOGV("MPEG4 Header");
  531
+        LOGV("size %d",size);
  532
+        LOGV("type 0x%x", type);
  533
+        LOGV("data 0x%x", data);
  534
+
  535
+        uint8_t *ptr = (uint8_t *)data;
  536
+
  537
+        parse_vol(ptr, size, &profile, &level, &num_ref_frames, &interlaced);
  538
+
  539
+        LOGV("MPEG4  Profile %d Level %d RefFrames %d Interlaced %d ", profile,level,num_ref_frames,interlaced);
  540
+        meta_track->setInt32(kKeyVideoProfile, profile);
  541
+        meta_track->setInt32(kKeyVideoLevel, level);
  542
+        meta_track->setInt32(kKeyVideoInterlaced, interlaced);
  543
+        meta_track->setInt32(kKeyNumRefFrames, num_ref_frames);
  544
+
  545
+
  546
+    }
  547
+    else if ( meta_track->findData(kKeyAVCC, &type, &data, &size)) {
  548
+        LOGV("H264 Header");
  549
+        LOGV("size %d",size);
  550
+        LOGV("type 0x%x", type);
  551
+        LOGV("data 0x%x", data);
  552
+
  553
+        const uint8_t *ptr = (const uint8_t *)data;
  554
+
  555
+        CHECK(size >= 7);
  556
+        CHECK_EQ(ptr[0], 1);  // configurationVersion == 1
  557
+
  558
+        size_t numSeqParameterSets = ptr[5] & 31;
  559
+
  560
+        LOGV("numSeqParameterSets %d",numSeqParameterSets);
  561
+
  562
+        ptr += 6;
  563
+        size -= 6;
  564
+
  565
+        for (size_t i = 0; i < numSeqParameterSets; ++i) {
  566
+            CHECK(size >= 2);
  567
+            size_t length = U16_AT(ptr);
  568
+
  569
+            ptr += 2;
  570
+            size -= 2;
  571
+
  572
+            CHECK(size >= length);
  573
+
  574
+            parse_sps((uint8_t*)ptr, length, &profile, &level, &num_ref_frames, &interlaced);
  575
+
  576
+            LOGV("H264 Profile %d Level %d RefFrames %d Interlaced %d", profile,level,num_ref_frames,interlaced);
  577
+            meta_track->setInt32(kKeyVideoProfile, profile);
  578
+            meta_track->setInt32(kKeyVideoLevel, level);
  579
+            meta_track->setInt32(kKeyNumRefFrames, num_ref_frames);
  580
+            meta_track->setInt32(kKeyVideoInterlaced, interlaced);
  581
+
  582
+            ptr += length;
  583
+            size -= length;
  584
+        }
  585
+
  586
+    }
  587
+
  588
+    return;
  589
+}
  590
+
  591
+
  592
+}  // namespace android
  593
+
  594
+
  595
+#endif
  596
+
Txt media/libstagefright/WAVExtractor.cpp
... ...
@@ -316,9 +316,16 @@ status_t WAVSource::read(
316 316
     *out = NULL;
317 317
 
318 318
     int64_t seekTimeUs;
  319
+#ifdef OMAP_ENHANCEMENT
  320
+    size_t bytesPerSample = mBitsPerSample >> 3;
  321
+#endif
319 322
     ReadOptions::SeekMode mode;
320 323
     if (options != NULL && options->getSeekTo(&seekTimeUs, &mode)) {
  324
+#ifdef OMAP_ENHANCEMENT
  325
+        int64_t pos = (seekTimeUs * mSampleRate) / 1000000 * mNumChannels * bytesPerSample;
  326
+#else
321 327
         int64_t pos = (seekTimeUs * mSampleRate) / 1000000 * mNumChannels * 2;
  328
+#endif
322 329
         if (pos > mSize) {
323 330
             pos = mSize;
324 331
         }
... ...
@@ -353,7 +360,11 @@ status_t WAVSource::read(
353 360
         return ERROR_END_OF_STREAM;
354 361
     }
355 362
 
  363
+#ifdef OMAP_ENHANCEMENT
  364
+    int64_t offsetPos = n;
  365
+#else
356 366
     mCurrentPos += n;
  367
+#endif
357 368
 
358 369
     buffer->set_range(0, n);
359 370
 
... ...
@@ -398,13 +409,18 @@ status_t WAVSource::read(
398 409
         }
399 410
     }
400 411
 
  412
+
  413
+#ifndef OMAP_ENHANCEMENT
401 414
     size_t bytesPerSample = mBitsPerSample >> 3;
  415
+#endif
402 416
 
403 417
     buffer->meta_data()->setInt64(
404 418
             kKeyTime,
405 419
             1000000LL * (mCurrentPos - mOffset)
406 420
                 / (mNumChannels * bytesPerSample) / mSampleRate);
407  
-
  421
+#ifdef OMAP_ENHANCEMENT
  422
+    mCurrentPos += offsetPos;
  423
+#endif
408 424
     buffer->meta_data()->setInt32(kKeyIsSyncFrame, 1);
409 425
 
410 426
     *out = buffer;
Txt media/libstagefright/codecs/mp3dec/Android.mk
... ...
@@ -48,6 +48,11 @@ LOCAL_C_INCLUDES := \
48 48
         $(LOCAL_PATH)/src \
49 49
         $(LOCAL_PATH)/include
50 50
 
  51
+ifeq ($(OMAP_ENHANCEMENT),true)
  52
+    LOCAL_C_INCLUDES += hardware/ti/omx/ducati/domx/system/omx_core/inc/
  53
+endif
  54
+
  55
+
51 56
 LOCAL_CFLAGS := \
52 57
         -DOSCL_UNUSED_ARG=
53 58
 
Txt media/libstagefright/colorconversion/Android.mk
... ...
@@ -8,6 +8,10 @@ LOCAL_SRC_FILES:=                     \
8 8
 LOCAL_C_INCLUDES := \
9 9
         $(TOP)/frameworks/base/include/media/stagefright/openmax
10 10
 
  11
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
  12
+LOCAL_C_INCLUDES += hardware/ti/omx/ducati/domx/system/omx_core/inc
  13
+endif
  14
+
11 15
 LOCAL_SHARED_LIBRARIES :=       \
12 16
         libbinder               \
13 17
         libmedia                \
... ...
@@ -17,6 +21,10 @@ LOCAL_SHARED_LIBRARIES :=       \
17 21
         libsurfaceflinger_client\
18 22
         libcamera_client
19 23
 
  24
+ifeq ($(TARGET_BOARD_PLATFORM),omap4)
  25
+LOCAL_CFLAGS += -DTARGET_OMAP4 -DARM_4K_PAGE_SIZE=4096
  26
+endif
  27
+
20 28
 LOCAL_MODULE:= libstagefright_color_conversion
21 29
 
22 30
 include $(BUILD_SHARED_LIBRARY)
Txt media/libstagefright/colorconversion/ColorConverter.cpp
... ...
@@ -18,6 +18,10 @@
18 18
 #include <media/stagefright/ColorConverter.h>
19 19
 #include <media/stagefright/MediaDebug.h>
20 20
 
  21
+#if defined (TARGET_OMAP4) && defined (OMAP_ENHANCEMENT)
  22
+#include <OMX_TI_IVCommon.h>
  23
+#endif
  24
+
21 25
 namespace android {
22 26
 
23 27
 static const int OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00;
... ...
@@ -50,6 +54,10 @@ bool ColorConverter::isValid() const {
50 54
         case OMX_QCOM_COLOR_FormatYVU420SemiPlanar:
51 55
         case OMX_COLOR_FormatYUV420SemiPlanar:
52 56
         case QOMX_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka:
  57
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  58
+        case OMX_COLOR_FormatYUV420PackedSemiPlanar:
  59
+        case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar_Sequential_TopBottom:
  60
+#endif
53 61
             return true;
54 62
 
55 63
         default:
... ...
@@ -57,10 +65,18 @@ bool ColorConverter::isValid() const {
57 65
     }
58 66
 }
59 67
 
  68
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  69
+void ColorConverter::convert(
  70
+        size_t width, size_t height,
  71
+        const void *srcBits, size_t srcSkip,
  72
+        void *dstBits, size_t dstSkip,
  73
+        size_t dwidth, size_t dheight, size_t nOffset, bool interlaced) {
  74
+#else
60 75
 void ColorConverter::convert(
61 76
         size_t width, size_t height,
62 77
         const void *srcBits, size_t srcSkip,
63 78
         void *dstBits, size_t dstSkip) {
  79
+#endif
64 80
     CHECK_EQ(mDstFormat, OMX_COLOR_Format16bitRGB565);
65 81
 
66 82
     switch (mSrcFormat) {
... ...
@@ -88,7 +104,13 @@ void ColorConverter::convert(
88 104
             convertNV12Tile(
89 105
                     width, height, srcBits, srcSkip, dstBits, dstSkip);
90 106
             break;
91  
-
  107
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  108
+        case OMX_COLOR_FormatYUV420PackedSemiPlanar:
  109
+        case OMX_TI_COLOR_FormatYUV420PackedSemiPlanar_Sequential_TopBottom:
  110
+            convertYUV420PackedSemiPlanar(
  111
+                    width, height, dwidth, dheight,nOffset,srcBits, srcSkip, dstBits, dstSkip, interlaced);
  112
+            break;
  113
+#endif
92 114
         default:
93 115
         {
94 116
             CHECK(!"Should not be here. Unknown color conversion.");
... ...
@@ -359,6 +381,93 @@ void ColorConverter::convertYUV420SemiPlanar(
359 381
     }
360 382
 }
361 383
 
  384
+
  385
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  386
+void ColorConverter::convertYUV420PackedSemiPlanar(
  387
+        size_t width, size_t height,
  388
+        size_t displaywidth, size_t displayheight, size_t nOffset,
  389
+        const void *srcBits, size_t srcSkip,
  390
+        void *dstBits, size_t dstSkip, bool interlaced) {
  391
+
  392
+    CHECK((dstSkip & 3) == 0);
  393
+
  394
+    size_t stride = width;
  395
+
  396
+    if(srcSkip)
  397
+        stride = srcSkip;
  398
+
  399
+    uint8_t *kAdjustedClip = initClip();
  400
+
  401
+    uint32_t *dst_ptr = (uint32_t *)dstBits;
  402
+    const uint8_t *src_y = (const uint8_t *)srcBits;
  403
+
  404
+    uint32_t offx = nOffset  % stride;
  405
+    uint32_t offy = nOffset / stride;
  406
+
  407
+
  408
+    const uint8_t *src_u = (const uint8_t *)(src_y-nOffset) + (stride * height);
  409
+    src_u += ( ( stride * (offy/2) ) + offx );
  410
+
  411
+    const uint8_t *src_v = src_u + 1;
  412
+
  413
+    for (size_t y = 0; y < displayheight; ++y) {
  414
+        for (size_t x = 0; x < displaywidth; x += 2) {
  415
+
  416
+            signed y1 = (signed)src_y[x] - 16;    //Y pixel
  417
+            signed y2 = (signed)src_y[x + 1] - 16; //2nd Y pixel
  418
+
  419
+            signed u = (signed)src_u[x & ~1] - 128;   //U component
  420
+            signed v = (signed)src_u[(x & ~1) + 1] - 128; //V component
  421
+
  422
+            signed u_b = u * 517;
  423
+            signed u_g = -u * 100;
  424
+            signed v_g = -v * 208;
  425
+            signed v_r = v * 409;
  426
+
  427
+            signed tmp1 = y1 * 298;
  428
+            signed b1 = (tmp1 + u_b) / 256;
  429
+            signed g1 = (tmp1 + v_g + u_g) / 256;
  430
+            signed r1 = (tmp1 + v_r) / 256;
  431
+
  432
+            signed tmp2 = y2 * 298;
  433
+            signed b2 = (tmp2 + u_b) / 256;
  434
+            signed g2 = (tmp2 + v_g + u_g) / 256;
  435
+            signed r2 = (tmp2 + v_r) / 256;
  436
+
  437
+            uint32_t rgb1 =
  438
+                ((kAdjustedClip[r1] >> 3) << 11)
  439
+                | ((kAdjustedClip[g1] >> 2) << 5)
  440
+                | (kAdjustedClip[b1] >> 3);
  441
+
  442
+            uint32_t rgb2 =
  443
+                ((kAdjustedClip[r2] >> 3) << 11)
  444
+                | ((kAdjustedClip[g2] >> 2) << 5)
  445
+                | (kAdjustedClip[b2] >> 3);
  446
+
  447
+            dst_ptr[x / 2] = (rgb2 << 16) | rgb1;
  448
+        }
  449
+
  450
+        if(!interlaced){
  451
+            src_y += stride; //increment Y-pixel line
  452
+            if(y&1){
  453
+              src_u += stride; //increment U-V line
  454
+            }
  455
+        }
  456
+        else{
  457
+            /* Interlaced stream. Will have Sequential Top Bottom content*/
  458
+            /* Just extrapolate first half contnents from Y,UV planes */
  459
+            if(y&1){
  460
+                src_y += stride; //increment Y-pixel line, once for two lines
  461
+                if((y/2)&1){
  462
+                  src_u += stride; //increment U-V line, once for four lines
  463
+                }
  464
+            }
  465
+        }
  466
+        dst_ptr += dstSkip / 4;
  467
+    }
  468
+}
  469
+#endif
  470
+
362 471
 uint8_t *ColorConverter::initClip() {
363 472
     static const signed kClipMin = -278;
364 473
     static const signed kClipMax = 535;
Txt media/libstagefright/colorconversion/SoftwareRenderer.cpp
... ...
@@ -108,4 +108,12 @@ void SoftwareRenderer::render(
108 108
     mIndex = 1 - mIndex;
109 109
 }
110 110
 
  111
+#ifdef OMAP_ENHANCEMENT
  112
+Vector< sp<IMemory> > SoftwareRenderer::getBuffers(){
  113
+    // Not Implemented
  114
+    Vector< sp<IMemory> > mDummy;
  115
+    return mDummy;
  116
+}
  117
+#endif
  118
+
111 119
 }  // namespace android
Txt media/libstagefright/id3/Android.mk
... ...
@@ -4,6 +4,9 @@ include $(CLEAR_VARS)
4 4
 LOCAL_SRC_FILES := \
5 5
   ID3.cpp
6 6
 
  7
+LOCAL_C_INCLUDES:= \
  8
+        $(TOP)/frameworks/base/include/media/stagefright/openmax
  9
+
7 10
 LOCAL_MODULE := libstagefright_id3
8 11
 
9 12
 include $(BUILD_STATIC_LIBRARY)
Txt media/libstagefright/include/ASFExtractor.h
... ...
@@ -0,0 +1,93 @@
  1
+/*
  2
+ *****************************************************************************
  3
+ *
  4
+ *                                Android
  5
+ *                  ITTIAM SYSTEMS PVT LTD, BANGALORE
  6
+ *                           COPYRIGHT(C) 2010-20
  7
+ *
  8
+ *  This program  is  proprietary to  Ittiam  Systems  Private  Limited  and
  9
+ *  is protected under Indian  Copyright Law as an unpublished work. Its use
  10
+ *  and  disclosure  is  limited by  the terms  and  conditions of a license
  11
+ *  agreement. It may not be copied or otherwise  reproduced or disclosed to
  12
+ *  persons outside the licensee's organization except in accordance with the
  13
+ *  terms  and  conditions   of  such  an  agreement.  All  copies  and
  14
+ *  reproductions shall be the property of Ittiam Systems Private Limited and
  15
+ *  must bear this notice in its entirety.
  16
+ *
  17
+ *****************************************************************************
  18
+ */
  19
+/**
  20
+ *****************************************************************************
  21
+ *
  22
+ *  @file     ASFExtractor.h
  23
+ *
  24
+ *  @brief    This file contains definition of ASFExtractor class
  25
+ *
  26
+ *****************************************************************************
  27
+ */
  28
+
  29
+#ifndef ITTIAM_ASF_EXTRACTOR_H_
  30
+
  31
+#define ITTIAM_ASF_EXTRACTOR_H_
  32
+
  33
+#include <media/stagefright/MediaExtractor.h>
  34
+#include <utils/Vector.h>
  35
+
  36
+namespace android {
  37
+
  38
+struct AMessage;
  39
+class String8;
  40
+class ASFExtractorImpl;
  41
+
  42
+typedef struct ASF_WRAPER
  43
+{
  44
+    ASFExtractorImpl* (*ASFExtractor)(
  45
+        const sp<DataSource> &source);
  46
+
  47
+    void (*destructorASFExtractor)(ASFExtractorImpl *mHandle);
  48
+
  49
+    size_t (*countTracks)(ASFExtractorImpl *mHandle);
  50
+
  51
+    sp<MediaSource> (*getTrack)(
  52
+        size_t index, ASFExtractorImpl *mHandle);
  53
+
  54
+    sp<MetaData> (*getTrackMetaData)(
  55
+        size_t index,
  56
+        uint32_t flags,
  57
+        ASFExtractorImpl *mHandle);
  58
+
  59
+    sp<MetaData> (*getMetaData)(ASFExtractorImpl *mHandle);
  60
+
  61
+}ASF_WRAPER;
  62
+
  63
+class ASFExtractor : public MediaExtractor {
  64
+public:
  65
+    // Extractor assumes ownership of "source".
  66
+    ASFExtractor(const sp<DataSource> &source);
  67
+
  68
+    virtual size_t countTracks();
  69
+    virtual sp<MediaSource> getTrack(size_t index);
  70
+    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
  71
+
  72
+    virtual sp<MetaData> getMetaData();
  73
+
  74
+protected:
  75
+    virtual ~ASFExtractor();
  76
+
  77
+private:
  78
+    ASF_WRAPER *pASFParser;
  79
+    ASFExtractorImpl *mHandle;
  80
+};
  81
+
  82
+bool SniffASF(const sp<DataSource> &source,
  83
+              String8 *mimeType,
  84
+              float *confidence,
  85
+              sp<AMessage> *meta);
  86
+
  87
+bool isASFParserAvailable();
  88
+void closeASFLib();
  89
+
  90
+}  // namespace android
  91
+
  92
+#endif  // ITTIAM_ASF_EXTRACTOR_H_
  93
+
Txt media/libstagefright/include/AwesomePlayer.h
... ...
@@ -17,6 +17,12 @@
17 17
 #ifndef AWESOME_PLAYER_H_
18 18
 
19 19
 #define AWESOME_PLAYER_H_
  20
+#ifdef OMAP_ENHANCEMENT
  21
+#include <utils/Vector.h>
  22
+#if defined(TARGET_OMAP4)
  23
+#include "TISEIMessagesParser.h"
  24
+#endif
  25
+#endif
20 26
 
21 27
 #include "NuHTTPDataSource.h"
22 28
 #include "TimedEventQueue.h"
... ...
@@ -46,6 +52,13 @@ struct AwesomeRenderer : public RefBase {
46 52
 
47 53
     virtual status_t initCheck() const = 0;
48 54
     virtual void render(MediaBuffer *buffer) = 0;
  55
+#ifdef OMAP_ENHANCEMENT
  56
+    virtual Vector< sp<IMemory> > getBuffers() = 0;
  57
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie) {return false;}
  58
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling){};
  59
+    virtual void resizeRenderer(void* resize_params) = 0;
  60
+    virtual void requestRendererClone(bool enable) = 0;
  61
+#endif
49 62
 
50 63
 private:
51 64
     AwesomeRenderer(const AwesomeRenderer &);
... ...
@@ -89,13 +102,18 @@ struct AwesomePlayer {
89 102
 
90 103
     status_t suspend();
91 104
     status_t resume();
  105
+#ifdef OMAP_ENHANCEMENT
  106
+    status_t requestVideoCloneMode(bool enable);
  107
+#endif
92 108
 
93 109
     // This is a mask of MediaExtractor::Flags.
94 110
     uint32_t flags() const;
95 111
 
96 112
     void postAudioEOS();
97 113
     void postAudioSeekComplete();
98  
-
  114
+#ifdef OMAP_ENHANCEMENT
  115
+    void releaseRenderedBuffer(const sp<IMemory>& mem);
  116
+#endif
99 117
 private:
100 118
     friend struct AwesomeEvent;
101 119
 
... ...
@@ -113,6 +131,22 @@ private:
113 131
         AUTO_LOOPING        = 1024,
114 132
     };
115 133
 
  134
+#ifdef OMAP_ENHANCEMENT
  135
+    enum {
  136
+        HOLD_TO_RESUME      = 2048,
  137
+        MAX_RESOLUTION      = 414720, // 864x480(WVGA) - 720x576(D1-PAL)
  138
+    };
  139
+    enum {
  140
+         VID_MODE_NORMAL = 0,
  141
+         VID_MODE_CLONE = 1
  142
+      };
  143
+
  144
+    int mVideoMode;
  145
+#if defined(TARGET_OMAP4)
  146
+    S3D_params mS3Dparams;
  147
+#endif
  148
+#endif
  149
+
116 150
     mutable Mutex mLock;
117 151
     Mutex mMiscStateLock;
118 152
 
... ...
@@ -179,7 +213,15 @@ private:
179 213
     void postCheckAudioStatusEvent_l();
180 214
     status_t play_l();
181 215
 
  216
+#ifdef OMAP_ENHANCEMENT
  217
+    Vector<MediaBuffer*> mBuffersWithRenderer;
  218
+    bool mBufferReleaseCallbackSet;
  219
+    bool mIsFirstVideoBuffer;
  220
+    status_t mFirstVideoBufferResult;
  221
+    MediaBuffer *mFirstVideoBuffer;
  222
+#else
182 223
     MediaBuffer *mLastVideoBuffer;
  224
+#endif
183 225
     MediaBuffer *mVideoBuffer;
184 226
 
185 227
     sp<NuHTTPDataSource> mConnectingDataSource;
... ...
@@ -216,6 +258,12 @@ private:
216 258
         }
217 259
     } *mSuspensionState;
218 260
 
  261
+#if defined(TARGET_OMAP4) && defined(OMAP_ENHANCEMENT)
  262
+    bool configSEI2004Infos(OMX_OTHER_EXTRADATATYPE *extraData);
  263
+    bool configSEI2010Infos(OMX_OTHER_EXTRADATATYPE *extraData);
  264
+    void updateS3DRenderer();
  265
+#endif
  266
+
219 267
     status_t setDataSource_l(
220 268
             const char *uri,
221 269
             const KeyedVector<String8, String8> *headers = NULL);
... ...
@@ -263,6 +311,10 @@ private:
263 311
 
264 312
     AwesomePlayer(const AwesomePlayer &);
265 313
     AwesomePlayer &operator=(const AwesomePlayer &);
  314
+#ifdef OMAP_ENHANCEMENT
  315
+    const char* mExtractorType;
  316
+    sp<MediaExtractor> mExtractor;
  317
+#endif
266 318
 };
267 319
 
268 320
 }  // namespace android
Txt media/libstagefright/include/NuCachedSource2.h
... ...
@@ -53,8 +53,13 @@ private:
53 53
 
54 54
     enum {
55 55
         kPageSize            = 65536,
  56
+#ifndef OMAP_ENHANCEMENT
56 57
         kHighWaterThreshold  = 5 * 1024 * 1024,
57 58
         kLowWaterThreshold   = 512 * 1024,
  59
+#else
  60
+        kHighWaterThreshold  = 13 * 1024 * 1024,
  61
+        kLowWaterThreshold   = 14 * 512 * 1024,
  62
+#endif
58 63
 
59 64
         // Read data after a 15 sec timeout whether we're actively
60 65
         // fetching or not.
Txt media/libstagefright/include/OMX.h
... ...
@@ -88,6 +88,12 @@ public:
88 88
             node_id node, OMX_INDEXTYPE index,
89 89
             const void *params, size_t size);
90 90
 
  91
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  92
+    virtual status_t useBuffer(
  93
+            node_id node, OMX_U32 port_index, const sp<IMemory> &params,
  94
+            buffer_id *buffer, size_t size);
  95
+#endif
  96
+
91 97
     virtual status_t useBuffer(
92 98
             node_id node, OMX_U32 port_index, const sp<IMemory> &params,
93 99
             buffer_id *buffer);
... ...
@@ -123,6 +129,16 @@ public:
123 129
             size_t encodedWidth, size_t encodedHeight,
124 130
             size_t displayWidth, size_t displayHeight,
125 131
             int32_t rotationDegrees);
  132
+#ifdef OMAP_ENHANCEMENT
  133
+    virtual sp<IOMXRenderer> createRenderer(
  134
+            const sp<ISurface> &surface,
  135
+            const char *componentName,
  136
+            OMX_COLOR_FORMATTYPE colorFormat,
  137
+            size_t encodedWidth, size_t encodedHeight,
  138
+            size_t displayWidth, size_t displayHeight,
  139
+            int32_t rotationDegrees,
  140
+            int isS3D, int numOfOpBuffers);
  141
+#endif
126 142
 
127 143
     virtual void binderDied(const wp<IBinder> &the_late_who);
128 144
 
Txt media/libstagefright/include/OMXNodeInstance.h
... ...
@@ -49,6 +49,12 @@ struct OMXNodeInstance {
49 49
     status_t getConfig(OMX_INDEXTYPE index, void *params, size_t size);
50 50
     status_t setConfig(OMX_INDEXTYPE index, const void *params, size_t size);
51 51
 
  52
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  53
+    status_t useBuffer(
  54
+            OMX_U32 portIndex, const sp<IMemory> &params,
  55
+            OMX::buffer_id *buffer, size_t size);
  56
+#endif
  57
+
52 58
     status_t useBuffer(
53 59
             OMX_U32 portIndex, const sp<IMemory> &params,
54 60
             OMX::buffer_id *buffer);
Txt media/libstagefright/include/SampleTable.h
... ...
@@ -46,6 +46,10 @@ public:
46 46
 
47 47
     status_t setTimeToSampleParams(off_t data_offset, size_t data_size);
48 48
 
  49
+#ifdef OMAP_ENHANCEMENT
  50
+    status_t setTimeToSampleParamsCtts(off_t data_offset, size_t data_size);
  51
+#endif
  52
+
49 53
     status_t setSyncSampleParams(off_t data_offset, size_t data_size);
50 54
 
51 55
     ////////////////////////////////////////////////////////////////////////////
... ...
@@ -76,7 +80,9 @@ public:
76 80
             uint32_t flags);
77 81
 
78 82
     status_t findThumbnailSample(uint32_t *sample_index);
79  
-
  83
+#ifdef OMAP_ENHANCEMENT
  84
+  int32_t *mTimeToSampleCtts;
  85
+#endif
80 86
 protected:
81 87
     ~SampleTable();
82 88
 
... ...
@@ -124,6 +130,12 @@ private:
124 130
 
125 131
     SampleTable(const SampleTable &);
126 132
     SampleTable &operator=(const SampleTable &);
  133
+
  134
+#ifdef OMAP_ENHANCEMENT
  135
+    uint32_t mTimeToSampleCountCtts;
  136
+    int32_t *mCttsSampleBuffer;
  137
+#endif
  138
+
127 139
 };
128 140
 
129 141
 }  // namespace android
Txt media/libstagefright/include/SoftwareRenderer.h
... ...
@@ -42,6 +42,11 @@ public:
42 42
 
43 43
     virtual void render(
44 44
             const void *data, size_t size, void *platformPrivate);
  45
+#ifdef OMAP_ENHANCEMENT
  46
+    virtual Vector< sp<IMemory> > getBuffers();
  47
+    virtual void resizeRenderer(void* resize_params) {}
  48
+    virtual void requestRendererClone(bool enable) {}
  49
+#endif
45 50
 
46 51
 private:
47 52
     status_t mInitCheck;
Txt media/libstagefright/include/TISEIMessagesParser.h
... ...
@@ -0,0 +1,88 @@
  1
+/*
  2
+ * Copyright (C) Texas Instruments - http://www.ti.com/
  3
+ *
  4
+ * This library is free software; you can redistribute it and/or
  5
+ * modify it under the terms of the GNU Lesser General Public
  6
+ * License as published by the Free Software Foundation; either
  7
+ * version 2.1 of the License, or (at your option) any later version.
  8
+ *
  9
+ *
  10
+ * This library is distributed in the hope that it will be useful,
  11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13
+ * Lesser General Public License for more details.
  14
+ *
  15
+ *
  16
+ * You should have received a copy of the GNU Lesser General Public
  17
+ * License along with this library; if not, write to the Free Software
  18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  19
+ */
  20
+
  21
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  22
+
  23
+#ifndef TI_SEI_MESSAGES_PARSER_H_INCLUDED
  24
+#define TI_SEI_MESSAGES_PARSER_H_INCLUDED
  25
+
  26
+#include <utils/Log.h>
  27
+
  28
+namespace android {
  29
+
  30
+/*values for possible S3D modes*/
  31
+enum {
  32
+    S3D_MODE_OFF = 0,
  33
+    S3D_MODE_ON = 1,
  34
+    S3D_MODE_ANAGLYPH = 2,
  35
+};
  36
+
  37
+/*values for possible S3D format types*/
  38
+enum {
  39
+    S3D_FORMAT_NONE = 0,
  40
+    S3D_FORMAT_OVERUNDER,
  41
+    S3D_FORMAT_SIDEBYSIDE,
  42
+    S3D_FORMAT_ROW_IL,
  43
+    S3D_FORMAT_COL_IL,
  44
+    S3D_FORMAT_PIX_IL,
  45
+    S3D_FORMAT_CHECKB,
  46
+    S3D_FORMAT_FRM_SEQ,
  47
+};
  48
+
  49
+/*values for possible S3D order types*/
  50
+enum {
  51
+    S3D_ORDER_LF = 0,
  52
+    S3D_ORDER_RF,
  53
+};
  54
+
  55
+/*values for possible S3D subsampling modes*/
  56
+enum {
  57
+    S3D_SS_NONE = 0,
  58
+    S3D_SS_HOR,
  59
+    S3D_SS_VERT,
  60
+};
  61
+
  62
+/*values for possible S3D SEI messages types*/
  63
+enum {
  64
+    S3D_SEI_NONE = 0,                                   /* Regular Interlaced or Progressive stream */
  65
+    S3D_SEI_STEREO_INFO_PROGRESSIVE,    /* 2004 Progressive */
  66
+    S3D_SEI_STEREO_INFO_INTERLACED,     /*  2004 Interlaced */
  67
+    S3D_SEI_STEREO_FRAME_PACKING,       /*  2010 Progressive */
  68
+};
  69
+
  70
+struct S3D_params
  71
+{
  72
+    bool active;
  73
+    uint32_t mode;
  74
+    uint32_t fmt;
  75
+    uint32_t order;
  76
+    uint32_t subsampling;
  77
+    uint32_t metadata;
  78
+};
  79
+
  80
+#define AVC_NALTYPE_SEI 6  /* Supplemental Enhancement Info */
  81
+void set_frame_packing_arrangement_type(uint32_t frame_packing_arrangement_type, uint32_t &format, uint32_t &subsampling);
  82
+int32_t AVCGetNALType(uint8_t *bitstream, int size, int *nal_type, int *nal_ref_idc);
  83
+int16_t sei_rbsp(uint8_t *buffer, int32_t length, S3D_params &mS3Dparams);
  84
+
  85
+}
  86
+#endif //TI_M4V_CONFIG_PARSER_H_INCLUDED
  87
+#endif //OMAP_ENHANCEMENT
  88
+
Txt media/libstagefright/omx/OMX.cpp
... ...
@@ -306,6 +306,15 @@ status_t OMX::setConfig(
306 306
             index, params, size);
307 307
 }
308 308
 
  309
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  310
+status_t OMX::useBuffer(
  311
+        node_id node, OMX_U32 port_index, const sp<IMemory> &params,
  312
+        buffer_id *buffer, size_t size) {
  313
+    return findInstance(node)->useBuffer(
  314
+            port_index, params, buffer, size);
  315
+}
  316
+#endif
  317
+
309 318
 status_t OMX::useBuffer(
310 319
         node_id node, OMX_U32 port_index, const sp<IMemory> &params,
311 320
         buffer_id *buffer) {
... ...
@@ -484,6 +493,27 @@ struct SharedVideoRenderer : public VideoRenderer {
484 493
         return mObj->render(data, size, platformPrivate);
485 494
     }
486 495
 
  496
+#ifdef OMAP_ENHANCEMENT
  497
+    virtual Vector< sp<IMemory> > getBuffers() {
  498
+        return mObj->getBuffers();
  499
+    }
  500
+
  501
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie) {
  502
+        return mObj->setCallback(cb, cookie);
  503
+    }
  504
+
  505
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling) {
  506
+    mObj->set_s3d_frame_layout(s3d_mode, s3d_fmt, s3d_order, s3d_subsampling);
  507
+     }
  508
+
  509
+    virtual void resizeRenderer(void* resize_params) {
  510
+          mObj->resizeRenderer(resize_params);
  511
+    }
  512
+virtual void requestRendererClone(bool enable) {
  513
+    mObj->requestRendererClone(enable);
  514
+}
  515
+#endif
  516
+
487 517
 private:
488 518
     void *mLibHandle;
489 519
     VideoRenderer *mObj;
... ...
@@ -575,6 +605,86 @@ sp<IOMXRenderer> OMX::createRenderer(
575 605
     return new OMXRenderer(impl);
576 606
 }
577 607
 
  608
+#ifdef OMAP_ENHANCEMENT
  609
+sp<IOMXRenderer> OMX::createRenderer(
  610
+        const sp<ISurface> &surface,
  611
+        const char *componentName,
  612
+        OMX_COLOR_FORMATTYPE colorFormat,
  613
+        size_t encodedWidth, size_t encodedHeight,
  614
+        size_t displayWidth, size_t displayHeight,
  615
+        int32_t rotationDegrees,
  616
+        int isS3D, int numOfOpBuffers) {
  617
+    Mutex::Autolock autoLock(mLock);
  618
+    VideoRenderer *impl = NULL;
  619
+    void *libHandle = dlopen("libstagefrighthw.so", RTLD_NOW);
  620
+
  621
+    if (libHandle) {
  622
+        typedef VideoRenderer *(*CreateRendererWithRotationFunc)(
  623
+                const sp<ISurface> &surface,
  624
+                const char *componentName,
  625
+                OMX_COLOR_FORMATTYPE colorFormat,
  626
+                size_t displayWidth, size_t displayHeight,
  627
+                size_t decodedWidth, size_t decodedHeight,
  628
+                int32_t rotationDegrees,
  629
+                int isS3D, int numOfOpBuffers);
  630
+
  631
+        typedef VideoRenderer *(*CreateRendererFunc)(
  632
+                const sp<ISurface> &surface,
  633
+                const char *componentName,
  634
+                OMX_COLOR_FORMATTYPE colorFormat,
  635
+                size_t displayWidth, size_t displayHeight,
  636
+                size_t decodedWidth, size_t decodedHeight,
  637
+                int isS3D, int numOfOpBuffers);
  638
+
  639
+        CreateRendererWithRotationFunc funcWithRotation =
  640
+            (CreateRendererWithRotationFunc)dlsym(
  641
+                    libHandle,
  642
+                    "_Z26createRendererWithRotationRKN7android2spINS_8"
  643
+                    "ISurfaceEEEPKc20OMX_COLOR_FORMATTYPEjjjjiii");
  644
+
  645
+        if (funcWithRotation) {
  646
+            impl = (*funcWithRotation)(
  647
+                    surface, componentName, colorFormat,
  648
+                    displayWidth, displayHeight, encodedWidth, encodedHeight,
  649
+                    rotationDegrees,
  650
+                    isS3D, numOfOpBuffers);
  651
+        } else {
  652
+            CreateRendererFunc func =
  653
+                (CreateRendererFunc)dlsym(
  654
+                        libHandle,
  655
+                        "_Z14createRendererRKN7android2spINS_8ISurfaceEEEPKc20"
  656
+                        "OMX_COLOR_FORMATTYPEjjjjii");
  657
+            if (func) {
  658
+                impl = (*func)(surface, componentName, colorFormat,
  659
+                        displayWidth, displayHeight, encodedWidth, encodedHeight,
  660
+                        isS3D, numOfOpBuffers);
  661
+            }
  662
+        }
  663
+
  664
+        if (impl) {
  665
+            impl = new SharedVideoRenderer(libHandle, impl);
  666
+            libHandle = NULL;
  667
+        }
  668
+
  669
+        if (libHandle) {
  670
+            dlclose(libHandle);
  671
+            libHandle = NULL;
  672
+        }
  673
+    }
  674
+
  675
+    if (!impl) {
  676
+        LOGE("Using software renderer.");
  677
+        impl = new SoftwareRenderer(
  678
+                colorFormat,
  679
+                surface,
  680
+                displayWidth, displayHeight,
  681
+                encodedWidth, encodedHeight);
  682
+    }
  683
+
  684
+    return new OMXRenderer(impl);
  685
+}
  686
+#endif
  687
+
578 688
 OMXRenderer::OMXRenderer(VideoRenderer *impl)
579 689
     : mImpl(impl) {
580 690
 }
... ...
@@ -593,5 +703,28 @@ void OMXRenderer::render(IOMX::buffer_id buffer) {
593 703
             header->pPlatformPrivate);
594 704
 }
595 705
 
  706
+#ifdef OMAP_ENHANCEMENT
  707
+Vector< sp<IMemory> > OMXRenderer::getBuffers() {
  708
+    return mImpl->getBuffers();
  709
+}
  710
+
  711
+bool OMXRenderer::setCallback(release_rendered_buffer_callback cb, void *cookie) {
  712
+    return mImpl->setCallback(cb, cookie);
  713
+}
  714
+
  715
+void OMXRenderer::set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling) {
  716
+    mImpl->set_s3d_frame_layout(s3d_mode, s3d_fmt, s3d_order, s3d_subsampling);
  717
+}
  718
+
  719
+void OMXRenderer::resizeRenderer(void* resize_params) {
  720
+    mImpl->resizeRenderer(resize_params);
  721
+}
  722
+
  723
+void OMXRenderer::requestRendererClone(bool enable) {
  724
+    mImpl->requestRendererClone(enable);
  725
+}
  726
+
  727
+#endif
  728
+
596 729
 }  // namespace android
597 730
 
Txt media/libstagefright/omx/OMXNodeInstance.cpp
... ...
@@ -253,16 +253,42 @@ status_t OMXNodeInstance::setConfig(
253 253
     return StatusFromOMXError(err);
254 254
 }
255 255
 
  256
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
256 257
 status_t OMXNodeInstance::useBuffer(
257  
-        OMX_U32 portIndex, const sp<IMemory> &params,
258  
-        OMX::buffer_id *buffer) {
  258
+                OMX_U32 portIndex, const sp<IMemory> &params,
  259
+                OMX::buffer_id *buffer) {
  260
+        return useBuffer(portIndex, params, buffer, 0);
  261
+}
  262
+#endif
  263
+
  264
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  265
+status_t OMXNodeInstance::useBuffer(
  266
+                OMX_U32 portIndex, const sp<IMemory> &params,
  267
+                OMX::buffer_id *buffer, size_t size) {
  268
+#else
  269
+status_t OMXNodeInstance::useBuffer(
  270
+                OMX_U32 portIndex, const sp<IMemory> &params,
  271
+                OMX::buffer_id *buffer) {
  272
+#endif
259 273
     Mutex::Autolock autoLock(mLock);
260 274
 
261 275
     BufferMeta *buffer_meta = new BufferMeta(params);
262 276
 
263 277
     OMX_BUFFERHEADERTYPE *header;
264 278
 
265  
-#ifdef USE_GETBUFFERINFO
  279
+#if defined(OMAP_ENHANCEMENT) && defined(TARGET_OMAP4)
  280
+    OMX_ERRORTYPE err;
  281
+
  282
+    if(params.get() != NULL) {
  283
+        err = OMX_UseBuffer(
  284
+                mHandle, &header, portIndex, buffer_meta,
  285
+                params->size(), static_cast<OMX_U8 *>(params->pointer()));
  286
+    } else {
  287
+        err = OMX_UseBuffer(
  288
+                mHandle, &header, portIndex, buffer_meta,
  289
+                size, NULL);
  290
+    }
  291
+#elif defined(USE_GETBUFFERINFO)
266 292
     OMX_QCOM_PLATFORM_PRIVATE_PMEM_INFO pmem_info;
267 293
     ssize_t offset;
268 294
     size_t size;
Txt media/libstagefright/omx/OMXRenderer.h
... ...
@@ -31,6 +31,14 @@ public:
31 31
     virtual ~OMXRenderer();
32 32
 
33 33
     virtual void render(IOMX::buffer_id buffer);
  34
+#ifdef OMAP_ENHANCEMENT
  35
+    virtual Vector< sp<IMemory> > getBuffers();
  36
+    virtual bool setCallback(release_rendered_buffer_callback cb, void *cookie);
  37
+
  38
+    virtual void set_s3d_frame_layout(uint32_t s3d_mode, uint32_t s3d_fmt, uint32_t s3d_order, uint32_t s3d_subsampling);
  39
+    virtual void resizeRenderer(void* resize_params);
  40
+    virtual void requestRendererClone(bool enable);
  41
+#endif
34 42
 
35 43
 private:
36 44
     VideoRenderer *mImpl;
Txt omapmmlib/Android.mk
... ...
@@ -0,0 +1,44 @@
  1
+#
  2
+# Copyright (C) 2008 The Android Open Source Project
  3
+#
  4
+# Licensed under the Apache License, Version 2.0 (the "License");
  5
+# you may not use this file except in compliance with the License.
  6
+# You may obtain a copy of the License at
  7
+#
  8
+#      http://www.apache.org/licenses/LICENSE-2.0
  9
+#
  10
+# Unless required by applicable law or agreed to in writing, software
  11
+# distributed under the License is distributed on an "AS IS" BASIS,
  12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+# See the License for the specific language governing permissions and
  14
+# limitations under the License.
  15
+#
  16
+
  17
+# This makefile shows how to build your own shared library that can be
  18
+# shipped on the system of a phone, and included additional examples of
  19
+# including JNI code with the library and writing controller applications against it.
  20
+
  21
+LOCAL_PATH := $(call my-dir)
  22
+
  23
+# the library
  24
+# ============================================================
  25
+include $(CLEAR_VARS)
  26
+
  27
+LOCAL_SRC_FILES := \
  28
+            $(call all-subdir-java-files)
  29
+
  30
+LOCAL_MODULE_TAGS := optional
  31
+
  32
+# This is the target being built.
  33
+LOCAL_MODULE:= com.ti.omap.omap_mm_library
  34
+
  35
+include $(BUILD_JAVA_LIBRARY)
  36
+
  37
+# The JNI component
  38
+# ============================================================
  39
+# Also build all of the sub-targets under this one: the library's
  40
+# associated JNI code, and a sample controller of the library.
  41
+include $(CLEAR_VARS)
  42
+
  43
+include $(call all-makefiles-under,$(LOCAL_PATH))
  44
+
Txt omapmmlib/com.ti.omap.omap_mm_library.xml
... ...
@@ -0,0 +1,5 @@
  1
+<?xml version="1.0" encoding="utf-8"?>
  2
+<permissions>
  3
+    <library name="com.ti.omap.omap_mm_library"
  4
+            file="/system/framework/com.ti.omap.omap_mm_library.jar"/>
  5
+</permissions>
Txt omapmmlib/java/com/ti/omap/omap_mm_library/OmapMMLibrary.java
... ...
@@ -0,0 +1,65 @@
  1
+/*
  2
+ * Copyright (C) 2008 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package com.ti.omap.omap_mm_library;
  18
+
  19
+import android.util.Config;
  20
+import android.util.Log;
  21
+import android.view.Surface;
  22
+import android.view.SurfaceHolder;
  23
+import android.media.MediaPlayer;
  24
+
  25
+public final class OmapMMLibrary {
  26
+private String TAG = "OmapMMJavaLib";
  27
+static {
  28
+        /*
  29
+        * Load the library.  If it's already loaded, this does nothing.
  30
+        */
  31
+        System.loadLibrary("omap_mm_library_jni");
  32
+    }
  33
+
  34
+    private Surface mSurface; // accessed by native methods
  35
+    private MediaPlayer mMediaPlayer; // accessed by native methods
  36
+
  37
+    public OmapMMLibrary() {
  38
+    }
  39
+
  40
+    public void setVideoSurface(SurfaceHolder sh) {
  41
+        if (sh != null) {
  42
+            mSurface = sh.getSurface();
  43
+        } else {
  44
+            mSurface = null;
  45
+      return;
  46
+        }
  47
+        //This is native implemented, to get the associated ISurface
  48
+        setVideoISurface();
  49
+    }
  50
+
  51
+    public void setMediaPlayer(MediaPlayer mp) {
  52
+            mMediaPlayer = mp;
  53
+      return;
  54
+        }
  55
+
  56
+    /*
  57
+    * init will mount required fields
  58
+    */
  59
+    native public void native_init();
  60
+    native private void deinit();
  61
+    native public void setVideoISurface();
  62
+    native public void setDisplayId(int displayId);
  63
+
  64
+}
  65
+
Txt omapmmlib/java/com/ti/omap/omap_mm_library/UiCloningService.java
... ...
@@ -0,0 +1,71 @@
  1
+/*
  2
+ * Copyright (C) 2008 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+package com.ti.omap.omap_mm_library;
  18
+
  19
+import android.content.Context;
  20
+import android.content.BroadcastReceiver;
  21
+import android.content.Intent;
  22
+import android.content.IntentFilter;
  23
+
  24
+import android.util.Log;
  25
+
  26
+public final class UiCloningService {
  27
+    private String TAG = "UiCloningService";
  28
+
  29
+    static {
  30
+        /*
  31
+         * Load the library.  If it's already loaded, this does nothing.
  32
+         */
  33
+        System.loadLibrary("omap_mm_library_jni");
  34
+    }
  35
+
  36
+    // All possible Display Types on OMAP4.
  37
+    private static final int DISPLAY_TYPE_NONE          = -1;
  38
+    private static final int DISPLAY_TYPE_LCD_SECONDARY = 1;
  39
+    private static final int DISPLAY_TYPE_HDMI_TV       = 2;
  40
+
  41
+    private static final String ACTION_HDMI_PLUG = "android.intent.action.HDMI_PLUG";
  42
+    // Broadcast receiver for device connections intent broadcasts
  43
+    private final BroadcastReceiver mReceiver = new UiCloningBroadcastReceiver();
  44
+
  45
+    public UiCloningService(Context context) {
  46
+        IntentFilter intentFilter = new IntentFilter(ACTION_HDMI_PLUG);
  47
+        context.registerReceiver(mReceiver, intentFilter);
  48
+    }
  49
+
  50
+    private class UiCloningBroadcastReceiver extends BroadcastReceiver {
  51
+        @Override
  52
+        public void onReceive(Context context, Intent intent) {
  53
+            String action = intent.getAction();
  54
+
  55
+            if (action.equals(ACTION_HDMI_PLUG)) {
  56
+                int state = intent.getIntExtra("state", 0);
  57
+
  58
+                if(state==1) {
  59
+                    Log.d(TAG, "UiCloningBroadcastReceiver.onReceive() : Cloning UI to HDMI-TV");
  60
+                    CloneUiToDisplay(DISPLAY_TYPE_HDMI_TV);
  61
+                } else {
  62
+                    Log.d(TAG, "UiCloningBroadcastReceiver.onReceive() : Stopping UI on HDMI-TV");
  63
+                    CloneUiToDisplay(DISPLAY_TYPE_NONE);
  64
+                }
  65
+            }
  66
+        }
  67
+    }
  68
+
  69
+    native public void CloneUiToDisplay(int displayId);
  70
+}
  71
+
Txt omapmmlib/jni/Android.mk
... ...
@@ -0,0 +1,61 @@
  1
+#
  2
+# Copyright (C) 2008 The Android Open Source Project
  3
+#
  4
+# Licensed under the Apache License, Version 2.0 (the "License");
  5
+# you may not use this file except in compliance with the License.
  6
+# You may obtain a copy of the License at
  7
+#
  8
+#      http://www.apache.org/licenses/LICENSE-2.0
  9
+#
  10
+# Unless required by applicable law or agreed to in writing, software
  11
+# distributed under the License is distributed on an "AS IS" BASIS,
  12
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+# See the License for the specific language governing permissions and
  14
+# limitations under the License.
  15
+#
  16
+
  17
+# This makefile supplies the rules for building a library of JNI code for
  18
+# use by our example platform shared library.
  19
+
  20
+ifeq ($(OMAP_ENHANCEMENT),true)
  21
+LOCAL_PATH:= $(call my-dir)
  22
+include $(CLEAR_VARS)
  23
+
  24
+LOCAL_MODULE_TAGS := optional
  25
+
  26
+# This is the target being built.
  27
+LOCAL_MODULE:= libomap_mm_library_jni
  28
+
  29
+# All of the source files that we will compile.
  30
+LOCAL_SRC_FILES:= \
  31
+            OmapMMLibrary.cpp \
  32
+            UiCloningService.cpp
  33
+
  34
+# All of the shared libraries we link against.
  35
+LOCAL_SHARED_LIBRARIES := \
  36
+        libandroid_runtime \
  37
+        libnativehelper \
  38
+        libcutils \
  39
+        libutils\
  40
+        libbinder \
  41
+        libui \
  42
+        libsurfaceflinger_client \
  43
+        libmedia
  44
+
  45
+# No static libraries.
  46
+LOCAL_STATIC_LIBRARIES :=
  47
+
  48
+# Also need the JNI headers.
  49
+LOCAL_C_INCLUDES := \
  50
+        frameworks/base/core/libs \
  51
+        $(JNI_H_INCLUDE)
  52
+
  53
+# No special compiler flags.
  54
+LOCAL_CFLAGS +=
  55
+
  56
+# Don't prelink this library.  For more efficient code, you may want
  57
+# to add this library to the prelink map and set this to true.
  58
+LOCAL_PRELINK_MODULE := false
  59
+
  60
+include $(BUILD_SHARED_LIBRARY)
  61
+endif
Txt omapmmlib/jni/OmapMMLibrary.cpp
... ...
@@ -0,0 +1,309 @@
  1
+/*
  2
+ * Copyright (C) 2008 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+#define LOG_TAG "OmapMMLibrary"
  18
+#include "utils/Log.h"
  19
+
  20
+#include <stdlib.h>
  21
+#include <string.h>
  22
+#include <unistd.h>
  23
+#include <assert.h>
  24
+#include <stdio.h>
  25
+
  26
+#include "jni.h"
  27
+#include <surfaceflinger/Surface.h>
  28
+#include <surfaceflinger/ISurface.h>
  29
+#include <binder/Parcel.h>
  30
+#include <utils/RefBase.h>
  31
+#include <media/mediaplayer.h>
  32
+
  33
+using namespace android;
  34
+
  35
+// ----------------------------------------------------------------------------
  36
+namespace android {
  37
+//friend class for Surface, so that it can extract ISurface
  38
+class OmapMMLibrary {
  39
+    public:
  40
+        void getISurface(const sp<Surface>& s) {
  41
+            mSurface =  s->getISurface();
  42
+            return;
  43
+        }
  44
+    sp<ISurface> mSurface;
  45
+    };
  46
+}
  47
+
  48
+static OmapMMLibrary omapmmlib;
  49
+/*
  50
+ * Field/method IDs and class object references.
  51
+ *
  52
+ * You should not need to store the JNIEnv pointer in here.  It is
  53
+ * thread-specific and will be passed back in on every call.
  54
+ */
  55
+struct fields_t{
  56
+    jclass      omapMMLibraryClass;
  57
+    jfieldID    jniInt;
  58
+    jfieldID    mysurface;
  59
+    /* actually in android.view.Surface XXX */
  60
+    jfieldID    mysurface_native;
  61
+    jfieldID    mediaplayer;
  62
+    jfieldID    mediaplayer_native;
  63
+};
  64
+
  65
+static fields_t fields;
  66
+
  67
+// ----------------------------------------------------------------------------
  68
+
  69
+/*
  70
+ * Helper function to throw an arbitrary exception.
  71
+ *
  72
+ * Takes the exception class name, a format string, and one optional integer
  73
+ * argument (useful for including an error code, perhaps from errno).
  74
+ */
  75
+static void jniThrowException(JNIEnv* env, const char* ex, const char* fmt,
  76
+    int data) {
  77
+        if (jclass cls = env->FindClass(ex)) {
  78
+            if (fmt != NULL) {
  79
+                char msg[1000];
  80
+                snprintf(msg, sizeof(msg), fmt, data);
  81
+                env->ThrowNew(cls, msg);
  82
+            } else {
  83
+                env->ThrowNew(cls, NULL);
  84
+            }
  85
+        /*
  86
+         * This is usually not necessary -- local references are released
  87
+         * automatically when the native code returns to the VM.  It's
  88
+         * required if the code doesn't actually return, e.g. it's sitting
  89
+         * in a native event loop.
  90
+         */
  91
+        env->DeleteLocalRef(cls);
  92
+    }
  93
+}
  94
+/**
  95
+  Initialization steps:
  96
+  1. init fields
  97
+**/
  98
+static void OmapMMLibrary_native_init(JNIEnv* env, jclass clazz1) {
  99
+    static const char* const kClassName =
  100
+        "com/ti/omap/omap_mm_library/OmapMMLibrary";
  101
+    jclass clazz;
  102
+
  103
+    /* look up the class */
  104
+    clazz = env->FindClass(kClassName);
  105
+    if (clazz == NULL) {
  106
+        LOGE("Can't find class %s\n", kClassName);
  107
+        return;
  108
+    }
  109
+
  110
+       fields.mysurface = env->GetFieldID(clazz, "mSurface", "Landroid/view/Surface;");
  111
+    if (fields.mysurface == NULL) {
  112
+        jniThrowException(env, "java/lang/RuntimeException", "Can't find MMLibrary.mSurface", 0);
  113
+        return;
  114
+    }
  115
+
  116
+    jclass mysurface = env->FindClass("android/view/Surface");
  117
+    if (mysurface == NULL) {
  118
+        jniThrowException(env, "java/lang/RuntimeException", "Can't find android/view/Surface", 0);
  119
+        return;
  120
+    }
  121
+
  122
+    fields.mysurface_native = env->GetFieldID(mysurface, "mNativeSurface", "I");
  123
+    if (fields.mysurface_native == NULL) {
  124
+        jniThrowException(env, "java/lang/RuntimeException", "Can't find Surface.mSurface", 0);
  125
+        return;
  126
+    }
  127
+
  128
+    fields.mediaplayer = env->GetFieldID(clazz, "mMediaPlayer", "Landroid/media/MediaPlayer;");
  129
+    if (fields.mediaplayer == NULL) {
  130
+        jniThrowException(env, "java/lang/RuntimeException", "Can't find android/media/MediaPlayer", 0);
  131
+        return;
  132
+    }
  133
+
  134
+    jclass mp = env->FindClass("android/media/MediaPlayer");
  135
+    if (mp == NULL) {
  136
+        jniThrowException(env, "java/lang/RuntimeException", "Can't find android/media/MediaPlayer", 0);
  137
+        return;
  138
+    }
  139
+
  140
+    fields.mediaplayer_native = env->GetFieldID(mp, "mNativeContext", "I");
  141
+    if (fields.mediaplayer_native == NULL) {
  142
+        jniThrowException(env, "java/lang/RuntimeException", "Can't find MediaPlayer.mNativeContext", 0);
  143
+        return;
  144
+    }
  145
+
  146
+
  147
+    return;
  148
+}
  149
+
  150
+/**
  151
+  Deinitialization steps:
  152
+  1. do nothing for now
  153
+**/
  154
+static void OmapMMLibrary_deinit(JNIEnv* env, jclass clazz) {
  155
+    return;
  156
+}
  157
+
  158
+
  159
+/**
  160
+* a method to set the requested Display Id.
  161
+*
  162
+* Input: integer between 0 and 3
  163
+* 0 - PRIMARY DISPLAY
  164
+* 1 - SECONDARY DISPLAY
  165
+* 2 - HDTV
  166
+* 3 - pico DLP
  167
+* these enums should be in sync with overlay enums
  168
+**/
  169
+static void OmapMMLibrary_setDisplayId(JNIEnv* env, jclass clazz, int displayId) {
  170
+    LOGD("displayId[%d]", displayId);
  171
+    jobject myplayer = env->GetObjectField(clazz, fields.mediaplayer);
  172
+    if (myplayer != NULL) { //media player would be null for switch usecases
  173
+        MediaPlayer* const p = (MediaPlayer*)env->GetIntField(myplayer, fields.mediaplayer_native);
  174
+        if (p) {
  175
+            if (displayId != 0) {
  176
+                p->requestVideoCloneMode(1);
  177
+            }
  178
+            else {
  179
+                p->requestVideoCloneMode(0);
  180
+            }
  181
+        }
  182
+    }
  183
+    if (omapmmlib.mSurface != NULL) {
  184
+        omapmmlib.mSurface->setDisplayId(displayId);
  185
+    }
  186
+    return;
  187
+}
  188
+
  189
+/**
  190
+* a method to set the ISurface for requested Surface.
  191
+* Surface was already set in JAVA class method.
  192
+*
  193
+**/
  194
+static void OmapMMLibrary_setVideoISurface(JNIEnv* env, jclass clazz) {
  195
+    jobject mysurface = env->GetObjectField(clazz, fields.mysurface);
  196
+    if (mysurface != NULL) {
  197
+        sp<Surface> native_surface = (Surface*)env->GetIntField(mysurface, fields.mysurface_native);
  198
+        //LOGD("surface=%p (id=%d)",native_surface.get(), native_surface->ID());
  199
+        if (native_surface.get() != NULL) {
  200
+            omapmmlib.getISurface(native_surface);
  201
+            //msurface is ready now
  202
+        }
  203
+    }
  204
+    return;
  205
+}
  206
+
  207
+// ----------------------------------------------------------------------------
  208
+
  209
+/*
  210
+ * Array of methods.
  211
+ *
  212
+ * Each entry has three fields: the name of the method, the method
  213
+ * signature, and a pointer to the native implementation.
  214
+ */
  215
+static const JNINativeMethod gMethods[] = {
  216
+    { "native_init","()V", (void*)OmapMMLibrary_native_init },
  217
+    { "deinit","()V", (void*)OmapMMLibrary_deinit },
  218
+    { "setVideoISurface","()V", (void*)OmapMMLibrary_setVideoISurface },
  219
+    { "setDisplayId","(I)V", (void*)OmapMMLibrary_setDisplayId },
  220
+};
  221
+
  222
+/*
  223
+ * Do some (slow-ish) lookups now and save the results.
  224
+ *
  225
+ * Returns 0 on success.
  226
+ */
  227
+static int cacheIds(JNIEnv* env, jclass clazz) {
  228
+    /*
  229
+     * Save the class in case we want to use it later.  Because this is a
  230
+     * reference to the Class object, we need to convert it to a JNI global
  231
+     * reference.
  232
+     */
  233
+    fields.omapMMLibraryClass = (jclass) env->NewGlobalRef(clazz);
  234
+    if (clazz == NULL) {
  235
+        LOGE("Can't create new global ref\n");
  236
+        return -1;
  237
+    }
  238
+
  239
+    return 0;
  240
+}
  241
+
  242
+/*
  243
+ * Explicitly register all methods for our class.
  244
+ *
  245
+ * While we're at it, cache some class references and method/field IDs.
  246
+ *
  247
+ * Returns 0 on success.
  248
+ */
  249
+static int registerMethods(JNIEnv* env) {
  250
+    static const char* const kClassName =
  251
+        "com/ti/omap/omap_mm_library/OmapMMLibrary";
  252
+    jclass clazz;
  253
+
  254
+    /* look up the class */
  255
+    clazz = env->FindClass(kClassName);
  256
+    if (clazz == NULL) {
  257
+        LOGE("Can't find class %s\n", kClassName);
  258
+        return -1;
  259
+    }
  260
+
  261
+    /* register all the methods */
  262
+    if (env->RegisterNatives(clazz, gMethods,
  263
+            sizeof(gMethods) / sizeof(gMethods[0])) != JNI_OK)
  264
+    {
  265
+        LOGE("Failed registering methods for %s\n", kClassName);
  266
+        return -1;
  267
+    }
  268
+
  269
+    /* fill out the rest of the ID cache */
  270
+    return cacheIds(env, clazz);
  271
+}
  272
+
  273
+extern int UiCloningService_registerMethods(JNIEnv* env);
  274
+
  275
+// ----------------------------------------------------------------------------
  276
+
  277
+/*
  278
+ * This is called by the VM when the shared library is first loaded.
  279
+ */
  280
+jint JNI_OnLoad(JavaVM* vm, void* reserved) {
  281
+    JNIEnv* env = NULL;
  282
+    jint result = -1;
  283
+
  284
+    if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
  285
+        LOGE("ERROR: GetEnv failed\n");
  286
+        goto bail;
  287
+    }
  288
+    assert(env != NULL);
  289
+
  290
+    if (registerMethods(env) != 0) {
  291
+        LOGE("ERROR: PlatformLibrary native registration failed\n");
  292
+        goto bail;
  293
+    }
  294
+
  295
+    if (UiCloningService_registerMethods(env) != 0) {
  296
+        LOGE("ERROR: PlatformLibrary native registration for UiCloningService failed\n");
  297
+        goto bail;
  298
+    }
  299
+
  300
+    /* success -- return valid version number */
  301
+    result = JNI_VERSION_1_4;
  302
+
  303
+bail:
  304
+    return result;
  305
+}
  306
+
  307
+
  308
+
  309
+
Txt omapmmlib/jni/UiCloningService.cpp
... ...
@@ -0,0 +1,203 @@
  1
+/*
  2
+ * Copyright (C) 2008 The Android Open Source Project
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License");
  5
+ * you may not use this file except in compliance with the License.
  6
+ * You may obtain a copy of the License at
  7
+ *
  8
+ *      http://www.apache.org/licenses/LICENSE-2.0
  9
+ *
  10
+ * Unless required by applicable law or agreed to in writing, software
  11
+ * distributed under the License is distributed on an "AS IS" BASIS,
  12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13
+ * See the License for the specific language governing permissions and
  14
+ * limitations under the License.
  15
+ */
  16
+
  17
+#define LOG_TAG "UiCloningService"
  18
+#include "utils/Log.h"
  19
+
  20
+#include "jni.h"
  21
+#include <binder/Parcel.h>
  22
+
  23
+#include <fcntl.h>
  24
+
  25
+using namespace android;
  26
+
  27
+/*
  28
+ * Notes for Currently supported UI-Cloning-Feature
  29
+ *
  30
+ * 1. fb0 is on Overlay0 which is on LCD1.
  31
+ * 2. fb1 is on Overlay1 which can go to LCD2 or TV.
  32
+ * 3. UI-Cloning is supported on LCD2 and TV.
  33
+ * 4. Cloning of only fb0 is supported.
  34
+ * 5. For cloning of fb0 on Overlay1, fb1 is switched off.
  35
+ */
  36
+
  37
+const char fb0Overlays [PATH_MAX] = "/sys/class/graphics/fb0/overlays";
  38
+const char fb1Overlays [PATH_MAX] = "/sys/class/graphics/fb1/overlays";
  39
+const char fb0FitToScreenOption[PATH_MAX] = "/sys/class/graphics/fb0/fit_to_screen";
  40
+const char overlay1ManagerName[PATH_MAX] = "/sys/devices/platform/omapdss/overlay1/manager";
  41
+const char overlay1ManagerEnabled[PATH_MAX] = "/sys/devices/platform/omapdss/overlay1/enabled";
  42
+
  43
+enum displayId {
  44
+    DISPLAYID_NONE = -1,
  45
+    DISPLAYID_LCDSECONDARY = 1,
  46
+    DISPLAYID_TVHDMI = 2,
  47
+};
  48
+
  49
+/*
  50
+ * Helper function to throw an arbitrary exception.
  51
+ *
  52
+ * Takes the exception class name, a format string
  53
+ */
  54
+static void jniThrowException(JNIEnv* env, const char* ex, const char* msg = NULL)
  55
+{
  56
+    if (jclass cls = env->FindClass(ex)) {
  57
+        env->ThrowNew(cls, msg);
  58
+        /*
  59
+         * This is usually not necessary -- local references are released
  60
+         * automatically when the native code returns to the VM.  It's
  61
+         * required if the code doesn't actually return, e.g. it's sitting
  62
+         * in a native event loop.
  63
+         */
  64
+        env->DeleteLocalRef(cls);
  65
+    }
  66
+}
  67
+
  68
+int sysfile_write(const char* pathname, const void* buf, size_t size) {
  69
+    int fd = open(pathname, O_WRONLY);
  70
+    if (fd == -1) {
  71
+        LOGE("Can't open [%s]", pathname);
  72
+        return -1;
  73
+    }
  74
+    size_t written_size = write(fd, buf, size);
  75
+    if (written_size < size) {
  76
+        LOGE("Can't write [%s]", pathname);
  77
+        close(fd);
  78
+        return -1;
  79
+    }
  80
+    if (close(fd) == -1) {
  81
+        LOGE("cant close [%s]", pathname);
  82
+        return -1;
  83
+    }
  84
+    return 0;
  85
+}
  86
+
  87
+/**
  88
+* a method to Clone UI to the requested Display Id.
  89
+*
  90
+* Input: integer between 0 and 3
  91
+* 0 - PRIMARY DISPLAY
  92
+* 1 - SECONDARY DISPLAY
  93
+* 2 - HDTV
  94
+* 3 - pico DLP
  95
+* these IDs should be in sync with overlay enums
  96
+**/
  97
+static void UiCloningService_CloneUiToDisplay(JNIEnv* env, jclass clazz, int displayId) {
  98
+    LOGD("UiCloningService_CloneUiToDisplay : DisplayId= [%d]", displayId);
  99
+
  100
+    // Clone UI on Other Display
  101
+    if(displayId == DISPLAYID_LCDSECONDARY|| displayId == DISPLAYID_TVHDMI) {
  102
+        if (sysfile_write(overlay1ManagerEnabled, "0", sizeof("0")) < 0) {
  103
+            LOGE("Failed to set overlay1/enabled = 0");
  104
+            goto end;
  105
+        }
  106
+
  107
+        if (sysfile_write(fb1Overlays, "", sizeof("")) < 0) {
  108
+            LOGE("Failed to set fb1/overlays = NULL");
  109
+            goto end;
  110
+        }
  111
+        if(displayId == DISPLAYID_LCDSECONDARY) {
  112
+            if (sysfile_write(overlay1ManagerName, "2lcd", sizeof("2lcd")) < 0) {
  113
+                LOGE("Failed to set overlay/manager = 2lcd");
  114
+                goto end;
  115
+            }
  116
+        } else if(displayId == DISPLAYID_TVHDMI) {
  117
+            if (sysfile_write(overlay1ManagerName, "tv", sizeof("tv")) < 0) {
  118
+                LOGE("Failed to set overlay/manager = tv");
  119
+                goto end;
  120
+            }
  121
+        }
  122
+        if (sysfile_write(fb0Overlays, "0,1", sizeof("0,1")) < 0) {
  123
+            LOGE("Failed to set fb0/overlays = 0,1");
  124
+            goto end;
  125
+        }
  126
+        if (sysfile_write(fb0FitToScreenOption, "1", sizeof("1")) < 0) {
  127
+            LOGE("Failed to set fb0/fit_to_screen = 1");
  128
+            goto end;
  129
+        }
  130
+        if (sysfile_write(overlay1ManagerEnabled, "1", sizeof("1")) < 0) {
  131
+            LOGE("Failed to set overlay1/enabled = 1");
  132
+            goto end;
  133
+        }
  134
+    }
  135
+    // Stop cloning UI on Other Display
  136
+    else if(displayId == DISPLAYID_NONE) {
  137
+        if (sysfile_write(overlay1ManagerEnabled, "0", sizeof("0")) < 0) {
  138
+            LOGE("Failed to set overlay1/enabled = 0");
  139
+            goto end;
  140
+        }
  141
+        if (sysfile_write(fb0Overlays, "0", sizeof("0")) < 0) {
  142
+            LOGE("Failed to set fb0/overlays = 0");
  143
+            goto end;
  144
+        }
  145
+        if (sysfile_write(fb0FitToScreenOption, "0", sizeof("0")) < 0) {
  146
+            LOGE("Failed to set fb0/fit_to_screen = 0");
  147
+            goto end;
  148
+        }
  149
+        if (sysfile_write(fb1Overlays, "1", sizeof("1")) < 0) {
  150
+            LOGE("Failed to set fb0/overlays = 1");
  151
+            goto end;
  152
+        }
  153
+        if (sysfile_write(overlay1ManagerName, "2lcd", sizeof("2lcd")) < 0) {
  154
+            LOGE("Failed to restore overlay/manager = 2lcd");
  155
+            goto end;
  156
+        }
  157
+    }
  158
+
  159
+end:
  160
+    return;
  161
+}
  162
+
  163
+// ----------------------------------------------------------------------------
  164
+
  165
+/*
  166
+ * Array of methods.
  167
+ *
  168
+ * Each entry has three fields: the name of the method, the method
  169
+ * signature, and a pointer to the native implementation.
  170
+ */
  171
+static const JNINativeMethod gMethods[] = {
  172
+    { "CloneUiToDisplay","(I)V", (void*)UiCloningService_CloneUiToDisplay },
  173
+};
  174
+
  175
+/*
  176
+ * Explicitly register all methods for our class.
  177
+ *
  178
+ * While we're at it, cache some class references and method/field IDs.
  179
+ *
  180
+ * Returns 0 on success.
  181
+ */
  182
+int UiCloningService_registerMethods(JNIEnv* env) {
  183
+    static const char* const kClassName =
  184
+        "com/ti/omap/omap_mm_library/UiCloningService";
  185
+    jclass clazz;
  186
+
  187
+    /* look up the class */
  188
+    clazz = env->FindClass(kClassName);
  189
+    if (clazz == NULL) {
  190
+        LOGE("Can't find class %s\n", kClassName);
  191
+        return -1;
  192
+    }
  193
+
  194
+    /* register all the methods */
  195
+    if (env->RegisterNatives(clazz, gMethods,
  196
+            sizeof(gMethods) / sizeof(gMethods[0])) != JNI_OK) {
  197
+        LOGE("Failed registering methods for %s\n", kClassName);
  198
+        return -1;
  199
+    }
  200
+
  201
+    return 0;
  202
+}
  203
+
Txt services/audioflinger/AudioFlinger.cpp
... ...
@@ -128,7 +128,9 @@ static bool settingsAllowed() {
128 128
 // ----------------------------------------------------------------------------
129 129
 AudioFlinger::AudioFlinger()
130 130
     : BnAudioFlinger(),
131  
-#ifdef HAVE_FM_RADIO
  131
+#ifdef OMAP_ENHANCEMENT
  132
+        mAudioHardware(0), mFmEnabled(false), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1)
  133
+#elif defined(HAVE_FM_RADIO)
132 134
         mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1),  mFmOn(false)
133 135
 #else
134 136
         mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1)
... ...
@@ -627,6 +629,11 @@ bool AudioFlinger::streamMute(int stream) const
627 629
 bool AudioFlinger::isStreamActive(int stream) const
628 630
 {
629 631
     Mutex::Autolock _l(mLock);
  632
+#ifdef OMAP_ENHANCEMENT
  633
+      if ((mFmEnabled ) &&  (stream == AudioSystem::MUSIC)) {
  634
+         return true;
  635
+     }
  636
+#endif
630 637
     for (uint32_t i = 0; i < mPlaybackThreads.size(); i++) {
631 638
         if (mPlaybackThreads.valueAt(i)->isStreamActive(stream)) {
632 639
             return true;
... ...
@@ -1088,12 +1095,19 @@ status_t AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args
1088 1095
 
1089 1096
 
1090 1097
 // ----------------------------------------------------------------------------
1091  
-
  1098
+#ifdef OMAP_ENHANCEMENT
  1099
+AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
  1100
+    :   ThreadBase(audioFlinger, id),
  1101
+        mMixBuffer(0), mSuspended(0), mBytesWritten(0), mFmInplay(false), mOutput(output),
  1102
+        mLastWriteTime(0), mNumWrites(0), mNumDelayedWrites(0), mInWrite(false),
  1103
+  mDevice(device)
  1104
+#else
1092 1105
 AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
1093 1106
     :   ThreadBase(audioFlinger, id),
1094 1107
         mMixBuffer(0), mSuspended(0), mBytesWritten(0), mOutput(output),
1095 1108
         mLastWriteTime(0), mNumWrites(0), mNumDelayedWrites(0), mInWrite(false),
1096 1109
         mDevice(device)
  1110
+#endif
1097 1111
 {
1098 1112
     readOutputParameters();
1099 1113
 
... ...
@@ -1504,6 +1518,15 @@ status_t AudioFlinger::PlaybackThread::getRenderPosition(uint32_t *halFrames, ui
1504 1518
     return mOutput->getRenderPosition(dspFrames);
1505 1519
 }
1506 1520
 
  1521
+#ifdef OMAP_ENHANCEMENT
  1522
+status_t AudioFlinger::PlaybackThread::setFMRxActive(bool state)
  1523
+{
  1524
+    LOGV("AudioFlinger::PlaybackThread::setFMRxActive(");
  1525
+    mFmInplay = state;
  1526
+    return NO_ERROR;
  1527
+}
  1528
+#endif
  1529
+
1507 1530
 uint32_t AudioFlinger::PlaybackThread::hasAudioSession(int sessionId)
1508 1531
 {
1509 1532
     Mutex::Autolock _l(mLock);
... ...
@@ -1629,7 +1652,11 @@ bool AudioFlinger::MixerThread::threadLoop()
1629 1652
             // put audio hardware into standby after short delay
1630 1653
             if UNLIKELY((!activeTracks.size() && systemTime() > standbyTime) ||
1631 1654
                         mSuspended) {
  1655
+#ifdef OMAP_ENHANCEMENT
  1656
+                if (!mStandby  && !mFmInplay){
  1657
+#else
1632 1658
                 if (!mStandby) {
  1659
+#endif
1633 1660
                     LOGV("Audio hardware entering standby, mixer %p, mSuspended %d\n", this, mSuspended);
1634 1661
                     mOutput->standby();
1635 1662
                     mStandby = true;
... ...
@@ -4634,6 +4661,22 @@ status_t AudioFlinger::setStreamOutput(uint32_t stream, int output)
4634 4661
     return NO_ERROR;
4635 4662
 }
4636 4663
 
  4664
+#ifdef OMAP_ENHANCEMENT
  4665
+status_t AudioFlinger::setFMRxActive(bool state)
  4666
+{
  4667
+     LOGV("setFMRxActive() ");
  4668
+    // check calling permissions
  4669
+    if (!settingsAllowed()) {
  4670
+        return PERMISSION_DENIED;
  4671
+    }
  4672
+
  4673
+    mFmEnabled = state;
  4674
+    for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
  4675
+       mPlaybackThreads.valueAt(i)->setFMRxActive(state);
  4676
+
  4677
+    return NO_ERROR;
  4678
+}
  4679
+#endif
4637 4680
 
4638 4681
 int AudioFlinger::newAudioSessionId()
4639 4682
 {
Txt services/audioflinger/AudioFlinger.h
... ...
@@ -108,7 +108,9 @@ public:
108 108
     virtual     bool        getMicMute() const;
109 109
 
110 110
     virtual     bool        isStreamActive(int stream) const;
111  
-
  111
+#ifdef OMAP_ENHANCEMENT
  112
+   virtual     status_t  setFMRxActive(bool state);
  113
+#endif
112 114
     virtual     status_t    setParameters(int ioHandle, const String8& keyValuePairs);
113 115
     virtual     String8     getParameters(int ioHandle, const String8& keys);
114 116
 
... ...
@@ -587,6 +589,9 @@ private:
587 589
         virtual     bool        streamMute(int stream) const;
588 590
 
589 591
                     bool        isStreamActive(int stream) const;
  592
+#ifdef OMAP_ENHANCEMENT
  593
+        virtual     status_t  setFMRxActive(bool state);
  594
+#endif
590 595
 
591 596
                     sp<Track>   createTrack_l(
592 597
                                     const sp<AudioFlinger::Client>& client,
... ...
@@ -666,6 +671,9 @@ private:
666 671
         int                             mSuspended;
667 672
         int                             mBytesWritten;
668 673
         bool                            mMasterMute;
  674
+#ifdef OMAP_ENHANCEMENT
  675
+        bool                            mFmInplay;
  676
+#endif
669 677
         SortedVector< wp<Track> >       mActiveTracks;
670 678
 
671 679
         virtual int             getTrackName_l() = 0;
... ...
@@ -1180,6 +1188,9 @@ private:
1180 1188
 
1181 1189
                 mutable     Mutex                   mHardwareLock;
1182 1190
                 AudioHardwareInterface*             mAudioHardware;
  1191
+#ifdef OMAP_ENHANCEMENT
  1192
+                bool                                mFmEnabled;
  1193
+#endif
1183 1194
     mutable     int                                 mHardwareStatus;
1184 1195
 
1185 1196
 
Txt services/audioflinger/AudioPolicyService.cpp
... ...
@@ -594,6 +594,16 @@ status_t AudioPolicyService::setStreamOutput(AudioSystem::stream_type stream,
594 594
     return af->setStreamOutput(stream, output);
595 595
 }
596 596
 
  597
+#ifdef OMAP_ENHANCEMENT
  598
+status_t AudioPolicyService::setFMRxActive(bool state)
  599
+{
  600
+    sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
  601
+    if (af == 0) return PERMISSION_DENIED;
  602
+
  603
+    return af->setFMRxActive(state);
  604
+}
  605
+#endif
  606
+
597 607
 status_t AudioPolicyService::moveEffects(int session, audio_io_handle_t srcOutput,
598 608
                                                audio_io_handle_t dstOutput)
599 609
 {
... ...
@@ -641,12 +651,6 @@ status_t AudioPolicyService::setFmVolume(float volume, int delayMs)
641 651
 }
642 652
 #endif
643 653
 
644  
-#ifdef OMAP_ENHANCEMENT
645  
-status_t AudioPolicyService::setFMRxActive(bool status) {
646  
-    return NO_ERROR;
647  
-}
648  
-#endif
649  
-
650 654
 // -----------  AudioPolicyService::AudioCommandThread implementation ----------
651 655
 
652 656
 AudioPolicyService::AudioCommandThread::AudioCommandThread(String8 name)
Txt services/audioflinger/AudioPolicyService.h
... ...
@@ -123,6 +123,9 @@ public:
123 123
                                      audio_io_handle_t output,
124 124
                                      int delayMs = 0);
125 125
     virtual status_t setStreamOutput(AudioSystem::stream_type stream, audio_io_handle_t output);
  126
+#ifdef OMAP_ENHANCEMENT
  127
+    virtual status_t setFMRxActive(bool state);
  128
+#endif
126 129
     virtual void setParameters(audio_io_handle_t ioHandle,
127 130
                                const String8& keyValuePairs,
128 131
                                int delayMs = 0);
... ...
@@ -137,10 +140,6 @@ public:
137 140
     virtual status_t setFmVolume(float volume, int delayMs = 0);
138 141
 #endif
139 142
 
140  
-#ifdef OMAP_ENHANCEMENT
141  
-    virtual status_t    setFMRxActive(bool status);
142  
-#endif
143  
-
144 143
 private:
145 144
                         AudioPolicyService();
146 145
     virtual             ~AudioPolicyService();
Txt services/camera/libcameraservice/Android.mk
... ...
@@ -109,4 +109,12 @@ ifeq ($(TARGET_USE_MOTO_CUSTOM_CAMERA_PARAMETERS),true)
109 109
     LOCAL_CFLAGS += -DMOTO_CUSTOM_PARAMETERS
110 110
 endif
111 111
 
  112
+ifeq ($(BOARD_OMAP3_WITH_FFC), true)
  113
+    LOCAL_CFLAGS += -DOMAP3_SECONDARY_CAMERA
  114
+endif
  115
+
  116
+ifeq ($(BOARD_HAS_OMAP3_FW3A_LIBCAMERA), true)
  117
+    LOCAL_CFLAGS += -DOMAP3_FW3A_LIBCAMERA
  118
+endif
  119
+
112 120
 include $(BUILD_SHARED_LIBRARY)
Txt services/camera/libcameraservice/CameraService.cpp
... ...
@@ -99,6 +99,22 @@ static void htcCameraSwitch(int cameraId)
99 99
 }
100 100
 #endif
101 101
 
  102
+#ifdef OMAP3_FW3A_LIBCAMERA
  103
+static void setOmapISPReserve(int state)
  104
+{
  105
+    char buffer[16];
  106
+    int fd;
  107
+
  108
+    if (access("/sys/devices/platform/omap3isp/isp_reserve", W_OK) == 0) {
  109
+        snprintf(buffer, sizeof(buffer), "%d", state);
  110
+
  111
+        fd = open("/sys/devices/platform/omap3isp/isp_reserve", O_WRONLY);
  112
+        write(fd, buffer, strlen(buffer));
  113
+        close(fd);
  114
+    }
  115
+}
  116
+#endif
  117
+
102 118
 // ----------------------------------------------------------------------------
103 119
 
104 120
 // This is ugly and only safe if we never re-create the CameraService, but
... ...
@@ -208,13 +224,26 @@ sp<ICamera> CameraService::connect(
208 224
 #if defined(BOARD_USE_FROYO_LIBCAMERA) || defined(BOARD_HAVE_HTC_FFC)
209 225
     htcCameraSwitch(cameraId);
210 226
 #endif
211  
-
212 227
     sp<CameraHardwareInterface> hardware = HAL_openCameraHardware(cameraId);
213 228
     if (hardware == NULL) {
214 229
         LOGE("Fail to open camera hardware (id=%d)", cameraId);
215 230
         return NULL;
216 231
     }
217 232
 
  233
+#if defined(OMAP3_FW3A_LIBCAMERA) && defined(OMAP3_SECONDARY_CAMERA)
  234
+    {
  235
+        CameraParameters params(hardware->getParameters());
  236
+        params.set("video-input", cameraId);
  237
+        /* FFC doesn't export its own parameter list... :( */
  238
+        if (cameraId) {
  239
+            params.set("picture-size-values", "1600x1200,1280x960,1280x720,640x480,512x384,320x240"); 
  240
+            params.set("focus-mode-values", "fixed");
  241
+        }
  242
+        hardware->setParameters(params);
  243
+    }
  244
+#endif
  245
+
  246
+
218 247
 #if defined(BOARD_USE_REVERSE_FFC)
219 248
     if (cameraId == 1) {
220 249
         /* Change default parameters for the front camera */
... ...
@@ -388,7 +417,9 @@ void CameraService::playSound(sound_kind kind) {
388 417
         int index;
389 418
         AudioSystem::getStreamVolumeIndex(AudioSystem::ENFORCED_AUDIBLE, &index);
390 419
         if (index != 0) {
  420
+#ifndef OMAP_ENHANCEMENT
391 421
             player->seekTo(0);
  422
+#endif
392 423
             player->start();
393 424
         }
394 425
     }
... ...
@@ -427,6 +458,13 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
427 458
         mOverlayW = 0;
428 459
         mOverlayH = 0;
429 460
 
  461
+#ifdef OMAP_ENHANCEMENT
  462
+  mS3DOverlay = false;
  463
+#endif
  464
+#ifdef OMAP3_FW3A_LIBCAMERA
  465
+        setOmapISPReserve(1);
  466
+#endif
  467
+
430 468
         // Callback is disabled by default
431 469
         mPreviewCallbackFlag = FRAME_CALLBACK_FLAG_NOOP;
432 470
         mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
... ...
@@ -576,6 +614,9 @@ void CameraService::Client::disconnect() {
576 614
     mHardware->cancelPicture();
577 615
     // Release the hardware resources.
578 616
     mHardware->release();
  617
+#ifdef OMAP3_FW3A_LIBCAMERA
  618
+    setOmapISPReserve(0);
  619
+#endif
579 620
     // Release the held overlay resources.
580 621
     if (mUseOverlay) {
581 622
 #if defined(USE_OVERLAY_FORMAT_YCbCr_420_SP) || defined(USE_OVERLAY_FORMAT_YCrCb_420_SP)
... ...
@@ -677,6 +718,12 @@ status_t CameraService::Client::registerPreviewBuffers() {
677 718
 
678 719
 status_t CameraService::Client::setOverlay() {
679 720
     int w, h;
  721
+#ifdef OMAP_ENHANCEMENT
  722
+    uint32_t overlayFormat;
  723
+    bool isS3d = false;
  724
+
  725
+#endif
  726
+
680 727
     CameraParameters params(mHardware->getParameters());
681 728
     params.getPreviewSize(&w, &h);
682 729
 
... ...
@@ -689,7 +736,46 @@ status_t CameraService::Client::setOverlay() {
689 736
     }
690 737
 #endif
691 738
 
692  
-    if (w != mOverlayW || h != mOverlayH || mOrientationChanged) {
  739
+#ifdef OMAP_ENHANCEMENT
  740
+
  741
+    ///Query the current preview pixel format from Camera HAL to create the overlay
  742
+    ///in that particular format
  743
+    const char *prevFormat = params.getPreviewFormat();
  744
+#if defined(TARGET_OMAP3)
  745
+    LOGD("Camera service Selected OVERLAY_FORMAT_CbYCrY_422_I");
  746
+    overlayFormat = OVERLAY_FORMAT_CbYCrY_422_I;
  747
+#else
  748
+    if(strcmp(prevFormat, CameraParameters::PIXEL_FORMAT_YUV422I)==0)
  749
+    {
  750
+        LOGD("Camera service Selected OVERLAY_FORMAT_CbYCrY_422_I");
  751
+        overlayFormat = OVERLAY_FORMAT_CbYCrY_422_I;
  752
+    }
  753
+    else if(strcmp(prevFormat, CameraParameters::PIXEL_FORMAT_YUV420SP)==0)
  754
+    {
  755
+        LOGD("Camera service Selected OVERLAY_FORMAT_YCbCr_420_SP");
  756
+        overlayFormat = OVERLAY_FORMAT_YCbCr_420_SP;
  757
+    }
  758
+    else if(strcmp(prevFormat, CameraParameters::PIXEL_FORMAT_RGB565)==0)
  759
+    {
  760
+        LOGD("Camera service Selected OVERLAY_FORMAT_RGB_565");
  761
+        overlayFormat = OVERLAY_FORMAT_RGB_565;
  762
+    }
  763
+    else
  764
+    {
  765
+        overlayFormat = OVERLAY_FORMAT_DEFAULT;
  766
+    }
  767
+#endif
  768
+
  769
+    if(params.get("s3d-supported")!= NULL && CameraParameters::TRUE != NULL)
  770
+        isS3d = strcmp(params.get("s3d-supported"), CameraParameters::TRUE) == 0;
  771
+#endif
  772
+
  773
+    if (w != mOverlayW || h != mOverlayH || mOrientationChanged
  774
+#ifdef OMAP_ENHANCEMENT
  775
+        || ((mOverlayFormat!=NULL) && (strcmp(prevFormat, mOverlayFormat)!=0))
  776
+        || (mS3DOverlay != isS3d)
  777
+#endif
  778
+    ) {
693 779
         // Force the destruction of any previous overlay
694 780
         sp<Overlay> dummy;
695 781
         mHardware->setOverlay(dummy);
... ...
@@ -700,6 +786,9 @@ status_t CameraService::Client::setOverlay() {
700 786
         }
701 787
 #endif
702 788
         mOrientationChanged = false;
  789
+#ifdef OMAP_ENHANCEMENT
  790
+        mS3DOverlay = isS3d;
  791
+#endif
703 792
     }
704 793
 
705 794
     status_t result = NO_ERROR;
... ...
@@ -714,6 +803,10 @@ status_t CameraService::Client::setOverlay() {
714 803
             // wait in the createOverlay call if the previous overlay is in the
715 804
             // process of being destroyed.
716 805
             for (int retry = 0; retry < 50; ++retry) {
  806
+#ifdef OMAP_ENHANCEMENT
  807
+                mOverlayRef = mSurface->createOverlay(w, h, overlayFormat,
  808
+                                      mOrientation, isS3d);
  809
+#else
717 810
                 mOverlayRef = mSurface->createOverlay(w, h,
718 811
 #if defined(USE_OVERLAY_FORMAT_YCbCr_420_SP)
719 812
                                                       HAL_PIXEL_FORMAT_YCbCr_420_SP,
... ...
@@ -723,6 +816,7 @@ status_t CameraService::Client::setOverlay() {
723 816
                                                       OVERLAY_FORMAT_DEFAULT,
724 817
 #endif
725 818
                                                       mOrientation);
  819
+#endif
726 820
                 if (mOverlayRef != 0) break;
727 821
                 LOGW("Overlay create failed - retrying");
728 822
                 usleep(20000);
... ...
@@ -747,6 +841,10 @@ status_t CameraService::Client::setOverlay() {
747 841
     mOverlayW = w;
748 842
     mOverlayH = h;
749 843
 
  844
+#ifdef OMAP_ENHANCEMENT
  845
+    strncpy(mOverlayFormat, prevFormat, OVERLAY_FORMAT_BUFFER_SIZE);
  846
+#endif
  847
+
750 848
     return result;
751 849
 }
752 850
 
... ...
@@ -812,6 +910,20 @@ status_t CameraService::Client::startPreviewMode() {
812 910
     LOG1("startPreviewMode");
813 911
     status_t result = NO_ERROR;
814 912
 
  913
+#ifdef OMAP_ENHANCEMENT
  914
+
  915
+    //According to framework documentation, preview should be
  916
+    //restarted after each capture. This will make sure
  917
+    //that image capture related messages get disabled if
  918
+    //not done already in their respective handlers.
  919
+    disableMsgType(CAMERA_MSG_SHUTTER |
  920
+                  CAMERA_MSG_POSTVIEW_FRAME |
  921
+                  CAMERA_MSG_RAW_IMAGE |
  922
+                  CAMERA_MSG_COMPRESSED_IMAGE |
  923
+                  CAMERA_MSG_BURST_IMAGE);
  924
+
  925
+#endif
  926
+
815 927
     // if preview has been enabled, nothing needs to be done
816 928
     if (mHardware->previewEnabled()) {
817 929
         return NO_ERROR;
... ...
@@ -889,7 +1001,23 @@ void CameraService::Client::stopPreview() {
889 1001
     LOG1("stopPreview (pid %d)", getCallingPid());
890 1002
     Mutex::Autolock lock(mLock);
891 1003
     if (checkPidAndHardware() != NO_ERROR) return;
  1004
+#ifdef OMAP_ENHANCEMENT
  1005
+
  1006
+    //According to framework documentation, preview needs
  1007
+    //to be started for image capture. This will make sure
  1008
+    //that image capture related messages get disabled if
  1009
+    //not done already in their respective handlers.
  1010
+    //If these messages come when in the midddle of
  1011
+    //stopping preview. We will deadlock the system in
  1012
+    //lockIfMessageWanted()
  1013
+
  1014
+    disableMsgType(CAMERA_MSG_SHUTTER |
  1015
+                  CAMERA_MSG_POSTVIEW_FRAME |
  1016
+                  CAMERA_MSG_RAW_IMAGE |
  1017
+                  CAMERA_MSG_COMPRESSED_IMAGE |
  1018
+                  CAMERA_MSG_BURST_IMAGE);
892 1019
 
  1020
+#endif
893 1021
     disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
894 1022
     mHardware->stopPreview();
895 1023
 
... ...
@@ -972,6 +1100,9 @@ status_t CameraService::Client::takePicture() {
972 1100
     enableMsgType(CAMERA_MSG_SHUTTER |
973 1101
                   CAMERA_MSG_POSTVIEW_FRAME |
974 1102
                   CAMERA_MSG_RAW_IMAGE |
  1103
+#ifdef OMAP_ENHANCEMENT
  1104
+                  CAMERA_MSG_BURST_IMAGE |
  1105
+#endif
975 1106
                   CAMERA_MSG_COMPRESSED_IMAGE);
976 1107
 
977 1108
     return mHardware->takePicture();
... ...
@@ -1088,6 +1219,14 @@ bool CameraService::Client::lockIfMessageWanted(int32_t msgType) {
1088 1219
             LOG1("lockIfMessageWanted(%d): enter sleep", msgType);
1089 1220
         }
1090 1221
         usleep(CHECK_MESSAGE_INTERVAL * 1000);
  1222
+#if (defined(TARGET_OMAP3) && defined(OMAP_ENHANCEMENT))
  1223
+        // Return true after 100ms. We don't want to enter in an infinite loop.
  1224
+        if (sleepCount == 10) {
  1225
+            LOGE("lockIfMessageWanted(%d): timed out in %d ms",
  1226
+                msgType, sleepCount * CHECK_MESSAGE_INTERVAL);
  1227
+            return true;
  1228
+        }
  1229
+#endif
1091 1230
     }
1092 1231
     LOGW("lockIfMessageWanted(%d): dropped unwanted message", msgType);
1093 1232
     return false;
... ...
@@ -1177,6 +1316,10 @@ void CameraService::Client::dataCallback(int32_t msgType,
1177 1316
     if (dataPtr == 0) {
1178 1317
         LOGE("Null data returned in data callback");
1179 1318
         client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
  1319
+#if (defined(TARGET_OMAP3) && defined(OMAP_ENHANCEMENT))
  1320
+        //Handle the NULL data returned in RawCallback from lower layers in OMAP3
  1321
+        client->handleGenericData(msgType, NULL);
  1322
+#endif
1180 1323
         return;
1181 1324
     }
1182 1325
 
... ...
@@ -1193,14 +1336,28 @@ void CameraService::Client::dataCallback(int32_t msgType,
1193 1336
         case CAMERA_MSG_COMPRESSED_IMAGE:
1194 1337
             client->handleCompressedPicture(dataPtr);
1195 1338
             break;
  1339
+
  1340
+#ifdef OMAP_ENHANCEMENT
  1341
+
  1342
+        case CAMERA_MSG_BURST_IMAGE:
  1343
+            client->handleBurstPicture(dataPtr);
  1344
+            break;
  1345
+
  1346
+#endif
  1347
+
1196 1348
         default:
1197 1349
             client->handleGenericData(msgType, dataPtr);
1198 1350
             break;
1199 1351
     }
1200 1352
 }
1201  
-
  1353
+#ifdef OMAP_ENHANCEMENT
  1354
+void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType,
  1355
+        const sp<IMemory>& dataPtr, void* user, uint32_t offset, uint32_t stride)
  1356
+#else
1202 1357
 void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp,
1203  
-        int32_t msgType, const sp<IMemory>& dataPtr, void* user) {
  1358
+        int32_t msgType, const sp<IMemory>& dataPtr, void* user)
  1359
+#endif
  1360
+{
1204 1361
     LOG2("dataCallbackTimestamp(%d)", msgType);
1205 1362
 
1206 1363
     sp<Client> client = getClientFromCookie(user);
... ...
@@ -1212,8 +1369,11 @@ void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp,
1212 1369
         client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
1213 1370
         return;
1214 1371
     }
1215  
-
  1372
+#ifdef OMAP_ENHANCEMENT
  1373
+    client->handleGenericDataTimestamp(timestamp, msgType, dataPtr, offset, stride);
  1374
+#else
1216 1375
     client->handleGenericDataTimestamp(timestamp, msgType, dataPtr);
  1376
+#endif
1217 1377
 }
1218 1378
 
1219 1379
 // snapshot taken callback
... ...
@@ -1372,6 +1532,22 @@ void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem) {
1372 1532
     }
1373 1533
 }
1374 1534
 
  1535
+#ifdef OMAP_ENHANCEMENT
  1536
+
  1537
+// burst callback
  1538
+void CameraService::Client::handleBurstPicture(const sp<IMemory>& mem) {
  1539
+    //Don't disable this message type yet. In this mode takePicture() will
  1540
+    //get called only once. When burst finishes this message will get automatically
  1541
+    //disabled in the respective call for restarting the preview.
  1542
+
  1543
+    sp<ICameraClient> c = mCameraClient;
  1544
+    mLock.unlock();
  1545
+    if (c != 0) {
  1546
+        c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem);
  1547
+    }
  1548
+}
  1549
+
  1550
+#endif
1375 1551
 
1376 1552
 void CameraService::Client::handleGenericNotify(int32_t msgType,
1377 1553
     int32_t ext1, int32_t ext2) {
... ...
@@ -1390,13 +1566,22 @@ void CameraService::Client::handleGenericData(int32_t msgType,
1390 1566
         c->dataCallback(msgType, dataPtr);
1391 1567
     }
1392 1568
 }
1393  
-
  1569
+#ifdef OMAP_ENHANCEMENT
  1570
+void CameraService::Client::handleGenericDataTimestamp(nsecs_t timestamp,
  1571
+    int32_t msgType, const sp<IMemory>& dataPtr, uint32_t offset, uint32_t stride)
  1572
+#else
1394 1573
 void CameraService::Client::handleGenericDataTimestamp(nsecs_t timestamp,
1395  
-    int32_t msgType, const sp<IMemory>& dataPtr) {
  1574
+    int32_t msgType, const sp<IMemory>& dataPtr)
  1575
+#endif
  1576
+{
1396 1577
     sp<ICameraClient> c = mCameraClient;
1397 1578
     mLock.unlock();
1398 1579
     if (c != 0) {
  1580
+#ifdef OMAP_ENHANCEMENT
  1581
+        c->dataCallbackTimestamp(timestamp, msgType, dataPtr, offset, stride);
  1582
+#else
1399 1583
         c->dataCallbackTimestamp(timestamp, msgType, dataPtr);
  1584
+#endif
1400 1585
     }
1401 1586
 }
1402 1587
 
... ...
@@ -1568,5 +1753,31 @@ extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId)
1568 1753
     return openCameraHardware(cameraId);
1569 1754
 }
1570 1755
 #endif
  1756
+#ifdef OMAP3_FW3A_LIBCAMERA
  1757
+static const CameraInfo sCameraInfo[] = {
  1758
+    {
  1759
+        CAMERA_FACING_BACK,
  1760
+        90,  /* orientation */
  1761
+    },
  1762
+#ifdef OMAP3_SECONDARY_CAMERA
  1763
+    {
  1764
+        CAMERA_FACING_FRONT,
  1765
+        270, /* orientation */
  1766
+    }
  1767
+#endif
  1768
+};
  1769
+static int getNumberOfCameras() {
  1770
+    return sizeof(sCameraInfo) / sizeof(sCameraInfo[0]);
  1771
+}
  1772
+
  1773
+extern "C" int HAL_getNumberOfCameras()
  1774
+{
  1775
+    return getNumberOfCameras();
  1776
+}
1571 1777
 
  1778
+extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo)
  1779
+{
  1780
+    memcpy(cameraInfo, &sCameraInfo[cameraId], sizeof(CameraInfo));
  1781
+}
  1782
+#endif
1572 1783
 }; // namespace android
Txt services/camera/libcameraservice/CameraService.h
... ...
@@ -26,7 +26,15 @@
26 26
 #include <camera/CameraHardwareInterface.h>
27 27
 
28 28
 /* This needs to be increased if we can have more cameras */
  29
+#ifdef OMAP_ENHANCEMENT
  30
+#define MAX_CAMERAS 3
  31
+#else
29 32
 #define MAX_CAMERAS 2
  33
+#endif
  34
+
  35
+#ifdef OMAP_ENHANCEMENT
  36
+#define OVERLAY_FORMAT_BUFFER_SIZE  40
  37
+#endif
30 38
 
31 39
 namespace android {
32 40
 
... ...
@@ -146,7 +154,12 @@ private:
146 154
         // these are static callback functions
147 155
         static void             notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user);
148 156
         static void             dataCallback(int32_t msgType, const sp<IMemory>& dataPtr, void* user);
  157
+#ifdef OMAP_ENHANCEMENT
  158
+        static      void        dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType,
  159
+                                        const sp<IMemory>& dataPtr, void* user, uint32_t offset=0, uint32_t stride=0);
  160
+#else
149 161
         static void             dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr, void* user);
  162
+#endif
150 163
         // convert client from cookie
151 164
         static sp<Client>       getClientFromCookie(void* user);
152 165
         // handlers for messages
... ...
@@ -158,10 +171,22 @@ private:
158 171
         void                    handlePreviewData(const sp<IMemory>& mem);
159 172
         void                    handlePostview(const sp<IMemory>& mem);
160 173
         void                    handleRawPicture(const sp<IMemory>& mem);
  174
+
  175
+#ifdef OMAP_ENHANCEMENT
  176
+
  177
+        void                    handleBurstPicture(const sp<IMemory>& mem);
  178
+
  179
+#endif
  180
+
161 181
         void                    handleCompressedPicture(const sp<IMemory>& mem);
162 182
         void                    handleGenericNotify(int32_t msgType, int32_t ext1, int32_t ext2);
163 183
         void                    handleGenericData(int32_t msgType, const sp<IMemory>& dataPtr);
  184
+#ifdef OMAP_ENHANCEMENT
  185
+        void                    handleGenericDataTimestamp(nsecs_t timestamp, int32_t msgType,
  186
+                                        const sp<IMemory>& dataPtr, uint32_t offset=0, uint32_t stride=0);
  187
+#else
164 188
         void                    handleGenericDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
  189
+#endif
165 190
 
166 191
         void                    copyFrameAndPostCopiedFrame(
167 192
                                     const sp<ICameraClient>& client,
... ...
@@ -214,6 +239,12 @@ private:
214 239
         // This function keeps trying to grab mLock, or give up if the message
215 240
         // is found to be disabled. It returns true if mLock is grabbed.
216 241
         bool                    lockIfMessageWanted(int32_t msgType);
  242
+
  243
+#ifdef OMAP_ENHANCEMENT
  244
+        char                     mOverlayFormat[OVERLAY_FORMAT_BUFFER_SIZE];
  245
+        bool                     mS3DOverlay;
  246
+#endif
  247
+
217 248
     };
218 249
 };
219 250
 
Txt services/camera/tests/CameraServiceTest/CameraServiceTest.cpp
... ...
@@ -297,6 +297,13 @@ public:
297 297
     virtual void unregisterBuffers();
298 298
     virtual sp<OverlayRef> createOverlay(
299 299
             uint32_t w, uint32_t h, int32_t format, int32_t orientation);
  300
+#ifdef OMAP_ENHANCEMENT
  301
+    virtual sp<OverlayRef> createOverlay(
  302
+            uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D);
  303
+    virtual void setDisplayId(int dpy);
  304
+    virtual int requestOverlayClone(bool enable);
  305
+#endif
  306
+
300 307
     virtual sp<GraphicBuffer> requestBuffer(int bufferIdx, int usage);
301 308
     virtual status_t setBufferCount(int bufferCount);
302 309
 
... ...
@@ -372,6 +379,26 @@ sp<OverlayRef> MSurface::createOverlay(uint32_t w, uint32_t h, int32_t format,
372 379
     return NULL;
373 380
 }
374 381
 
  382
+#ifdef OMAP_ENHANCEMENT
  383
+sp<OverlayRef> MSurface::createOverlay(uint32_t w, uint32_t h, int32_t format,
  384
+        int32_t orientation, int isS3D) {
  385
+    // We don't expect this to be called in current hardware.
  386
+    ASSERT(0);
  387
+    sp<OverlayRef> dummy;
  388
+    return dummy;
  389
+}
  390
+
  391
+void MSurface::setDisplayId(int dpy)
  392
+{
  393
+return;
  394
+}
  395
+
  396
+int MSurface::requestOverlayClone(bool enable)
  397
+{
  398
+return -1;
  399
+}
  400
+#endif
  401
+
375 402
 //
376 403
 //  Utilities to use the Holder service
377 404
 //
Txt services/java/com/android/server/NotificationManagerService.java
... ...
@@ -79,6 +79,10 @@ import java.util.HashMap;
79 79
 import java.util.Map;
80 80
 import java.util.Random;
81 81
 
  82
+/* TI FM UI port -start */
  83
+import android.os.SystemProperties;
  84
+/* TI FM UI port -stop */
  85
+
82 86
 /** {@hide} */
83 87
 public class NotificationManagerService extends INotificationManager.Stub
84 88
 {
... ...
@@ -1135,10 +1139,24 @@ public class NotificationManagerService extends INotificationManager.Stub
1135 1139
                     mSoundNotification = r;
1136 1140
                     // do not play notifications if stream volume is 0
1137 1141
                     // (typically because ringer mode is silent).
  1142
+
1138 1143
                     if (audioManager.getStreamVolume(audioStreamType) != 0) {
1139 1144
                         long identity = Binder.clearCallingIdentity();
1140 1145
                         try {
  1146
+
  1147
+                        /* TI FM UI port -start */
  1148
+                        if (SystemProperties.OMAP_ENHANCEMENT) {
  1149
+                             Slog.d(TAG,"sending mute to fm");
  1150
+                            String FM_MUTE_CMD = "com.ti.server.fmmutecmd";
  1151
+                            // Tell the FM playback service to Mute FM,
  1152
+                            // as the notification playback is starting.
  1153
+                            // TODO: these constants need to be published somewhere in the framework
  1154
+                            Intent fmmute = new Intent(FM_MUTE_CMD);
  1155
+                            mContext.sendBroadcast(fmmute);
1141 1156
                             mSound.play(mContext, uri, looping, audioStreamType);
  1157
+                         }
  1158
+                        /* TI FM UI port -stop */
  1159
+
1142 1160
                         }
1143 1161
                         finally {
1144 1162
                             Binder.restoreCallingIdentity(identity);
... ...
@@ -1285,6 +1303,16 @@ public class NotificationManagerService extends INotificationManager.Stub
1285 1303
             long identity = Binder.clearCallingIdentity();
1286 1304
             try {
1287 1305
                 mSound.stop();
  1306
+
  1307
+                /* TI FM UI port -start */
  1308
+                if (SystemProperties.OMAP_ENHANCEMENT) {
  1309
+                    String FM_UNMUTE_CMD = "com.ti.server.fmunmutecmd";
  1310
+                    /* Tell the FM playback service to unmute FM,as the notification playback is over.*/
  1311
+                    // TODO: these constants need to be published somewhere in the framework.
  1312
+                    Intent fmunmute = new Intent(FM_UNMUTE_CMD);
  1313
+                    mContext.sendBroadcast(fmunmute);
  1314
+                }
  1315
+                /* TI FM UI port - stop */
1288 1316
             }
1289 1317
             finally {
1290 1318
                 Binder.restoreCallingIdentity(identity);
Txt services/java/com/android/server/NotificationPlayer.java
... ...
@@ -33,6 +33,10 @@ import java.io.IOException;
33 33
 import java.lang.IllegalStateException;
34 34
 import java.lang.Thread;
35 35
 import java.util.LinkedList;
  36
+import android.content.Intent;
  37
+/* TI FM UI port -start */
  38
+import android.os.SystemProperties;
  39
+/* TI FM UI port -stop */
36 40
 
37 41
 /**
38 42
  * @hide
... ...
@@ -210,6 +214,18 @@ public class NotificationPlayer implements OnCompletionListener {
210 214
     }
211 215
 
212 216
     public void onCompletion(MediaPlayer mp) {
  217
+
  218
+        /* TI FM UI port -start */
  219
+        if (SystemProperties.OMAP_ENHANCEMENT) {
  220
+               String FM_UNMUTE_CMD = "com.ti.server.fmunmutecmd";
  221
+               Log.v(mTag,"sending unmute to fm");
  222
+               /* Tell the FM playback service to resume,as the notification playback is over*/
  223
+               // TODO: these constants need to be published somewhere in the framework.
  224
+               Intent fmunmute = new Intent(FM_UNMUTE_CMD);
  225
+               mCompletionThread.mCmd.context.sendBroadcast(fmunmute);
  226
+        }
  227
+        /* TI FM UI port -stop */
  228
+
213 229
         if (mAudioManager != null) {
214 230
             mAudioManager.abandonAudioFocus(null);
215 231
         }
Txt services/sensorservice/Android.mk
... ...
@@ -28,8 +28,11 @@ ifneq ($(TARGET_PROXIMITY_SENSOR_LIMIT),)
28 28
     LOCAL_CFLAGS += -DPROXIMITY_LIES=$(TARGET_PROXIMITY_SENSOR_LIMIT)
29 29
 endif
30 30
 
31  
-ifneq ($(filter p990 p999, $(TARGET_BOOTLOADER_BOARD_NAME)),)
  31
+ifneq ($(filter p990 p999 p970, $(TARGET_BOOTLOADER_BOARD_NAME)),)
32 32
     LOCAL_CFLAGS += -DUSE_LGE_ALS_DUMMY
  33
+    ifeq ($(TARGET_BOOTLOADER_BOARD_NAME),p970)
  34
+        LOCAL_CFLAGS += -DUSE_LGE_ALS_OMAP3
  35
+    endif
33 36
 endif
34 37
 
35 38
 # need "-lrt" on Linux simulator to pick up clock_gettime
Txt services/sensorservice/SensorDevice.cpp
... ...
@@ -306,7 +306,15 @@ status_t SensorDevice::activate(void* ident, int handle, int enabled)
306 306
         int nwr, ret, fd;
307 307
         char value[2];
308 308
 
  309
+#ifdef USE_LGE_ALS_OMAP3
  310
+        fd = open("/sys/class/leds/lcd-backlight/als", O_RDWR);
  311
+        if(fd < 0)
  312
+            return -ENODEV;
309 313
 
  314
+        nwr = sprintf(value, "%s\n", enabled ? "1" : "0");
  315
+        write(fd, value, nwr);
  316
+        close(fd);
  317
+#else
310 318
         fd = open("/sys/devices/platform/star_aat2870.0/lsensor_onoff", O_RDWR);
311 319
         if(fd < 0)
312 320
             return -ENODEV;
... ...
@@ -321,6 +329,7 @@ status_t SensorDevice::activate(void* ident, int handle, int enabled)
321 329
         nwr = sprintf(value, "%s\n", enabled ? "2" : "0");
322 330
         write(fd, value, nwr);
323 331
         close(fd);
  332
+#endif
324 333
 
325 334
         return 0;
326 335
 
Txt services/surfaceflinger/Android.mk
... ...
@@ -20,9 +20,11 @@ LOCAL_SRC_FILES:= \
20 20
 LOCAL_CFLAGS:= -DLOG_TAG=\"SurfaceFlinger\"
21 21
 LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES
22 22
 
  23
+ifneq ($(OMAP_ENHANCEMENT), true)
23 24
 ifeq ($(TARGET_BOARD_PLATFORM), omap3)
24 25
   LOCAL_CFLAGS += -DNO_RGBX_8888
25 26
 endif
  27
+endif
26 28
 
27 29
 ifeq ($(TARGET_DO_NOT_SETS_CAN_DRAW), true)
28 30
     LOCAL_CFLAGS += -DDO_NOT_SET_CAN_DRAW
Txt services/surfaceflinger/LayerBase.cpp
... ...
@@ -708,6 +708,26 @@ sp<OverlayRef> LayerBaseClient::Surface::createOverlay(
708 708
     return NULL;
709 709
 };
710 710
 
  711
+#ifdef OMAP_ENHANCEMENT
  712
+sp<OverlayRef> LayerBaseClient::Surface::createOverlay(
  713
+        uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D)
  714
+{
  715
+    return NULL;
  716
+};
  717
+
  718
+
  719
+void LayerBaseClient::Surface::setDisplayId(int displayId)
  720
+{
  721
+    return;
  722
+}
  723
+
  724
+int LayerBaseClient::Surface::requestOverlayClone(bool enable)
  725
+{
  726
+    return (-1);
  727
+}
  728
+
  729
+#endif
  730
+
711 731
 // ---------------------------------------------------------------------------
712 732
 
713 733
 }; // namespace android
Txt services/surfaceflinger/LayerBase.h
... ...
@@ -319,7 +319,12 @@ public:
319 319
         virtual void unregisterBuffers();
320 320
         virtual sp<OverlayRef> createOverlay(uint32_t w, uint32_t h,
321 321
                 int32_t format, int32_t orientation);
322  
-
  322
+#ifdef OMAP_ENHANCEMENT
  323
+        virtual sp<OverlayRef> createOverlay(uint32_t w, uint32_t h,
  324
+                int32_t format, int32_t orientation, int isS3D);
  325
+  virtual void setDisplayId(int displayId);
  326
+        virtual int requestOverlayClone(bool enable);
  327
+#endif
323 328
     protected:
324 329
         friend class LayerBaseClient;
325 330
         sp<SurfaceFlinger>  mFlinger;
Txt services/surfaceflinger/LayerBuffer.cpp
... ...
@@ -200,6 +200,37 @@ sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f,
200 200
     return result;
201 201
 }
202 202
 
  203
+#ifdef OMAP_ENHANCEMENT
  204
+sp<OverlayRef> LayerBuffer::createOverlay(uint32_t w, uint32_t h, int32_t f,
  205
+        int32_t orientation, int isS3D)
  206
+{
  207
+    sp<OverlayRef> result;
  208
+    Mutex::Autolock _l(mLock);
  209
+    if (mSource != 0)
  210
+        return result;
  211
+    sp<OverlaySource> source = new OverlaySource(*this, &result, w, h, f, orientation, isS3D);
  212
+    if (result != 0) {
  213
+        mSource = source;
  214
+    }
  215
+    return result;
  216
+}
  217
+
  218
+void LayerBuffer::setDisplayId(int displayId) {
  219
+    sp<Source> source(getSource());
  220
+    if (LIKELY(source != 0)) {
  221
+        source->setDisplayId(displayId);
  222
+    }
  223
+}
  224
+
  225
+int LayerBuffer::requestOverlayClone(bool enable) {
  226
+    sp<Source> source(getSource());
  227
+    if (LIKELY(source != 0)) {
  228
+        return (source->requestOverlayClone(enable));
  229
+    }
  230
+    return (-1);
  231
+}
  232
+#endif
  233
+
203 234
 sp<LayerBuffer::Source> LayerBuffer::getSource() const {
204 235
     Mutex::Autolock _l(mLock);
205 236
     return mSource;
... ...
@@ -260,6 +291,34 @@ sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay(
260 291
     return result;
261 292
 }
262 293
 
  294
+#ifdef OMAP_ENHANCEMENT
  295
+sp<OverlayRef> LayerBuffer::SurfaceLayerBuffer::createOverlay(
  296
+        uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D) {
  297
+    sp<OverlayRef> result;
  298
+    sp<LayerBuffer> owner(getOwner());
  299
+    if (owner != 0)
  300
+        result = owner->createOverlay(w, h, format, orientation, isS3D);
  301
+    return result;
  302
+}
  303
+
  304
+void LayerBuffer::SurfaceLayerBuffer::setDisplayId(int dpy) {
  305
+    sp<LayerBuffer> owner(getOwner());
  306
+    if(owner != 0)
  307
+        {
  308
+        owner->setDisplayId(dpy);
  309
+        }
  310
+}
  311
+
  312
+int LayerBuffer::SurfaceLayerBuffer::requestOverlayClone(bool enable) {
  313
+    sp<LayerBuffer> owner(getOwner());
  314
+    if(owner != 0) {
  315
+        return (owner->requestOverlayClone(enable));
  316
+    }
  317
+    return (-1);
  318
+}
  319
+
  320
+#endif
  321
+
263 322
 // ============================================================================
264 323
 // LayerBuffer::Buffer
265 324
 // ============================================================================
... ...
@@ -324,7 +383,14 @@ void LayerBuffer::Source::postBuffer(ssize_t offset) {
324 383
 }
325 384
 void LayerBuffer::Source::unregisterBuffers() {
326 385
 }
  386
+#ifdef OMAP_ENHANCEMENT
  387
+void LayerBuffer::Source::setDisplayId(int dpy) {
  388
+}
327 389
 
  390
+int LayerBuffer::Source::requestOverlayClone(bool enable) {
  391
+    return -1;
  392
+}
  393
+#endif
328 394
 // ---------------------------------------------------------------------------
329 395
 
330 396
 LayerBuffer::BufferSource::BufferSource(LayerBuffer& layer,
... ...
@@ -606,6 +672,23 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
606 672
     overlay_dev->setParameter(overlay_dev, overlay, 
607 673
             OVERLAY_DITHER, OVERLAY_ENABLE);
608 674
 
  675
+#ifdef OMAP_ENHANCEMENT
  676
+    //get the graphic plane pixel format and decide whether to use color key
  677
+    //or per-pixel alpha blend
  678
+    PixelFormat pixfmt = mLayer.mFlinger->getFormat();
  679
+    if ((pixfmt == PIXEL_FORMAT_RGBA_8888) || (pixfmt == PIXEL_FORMAT_BGRA_8888) || \
  680
+     (pixfmt == PIXEL_FORMAT_RGBA_5551) || (pixfmt == PIXEL_FORMAT_RGBA_4444))
  681
+    {
  682
+        overlay_dev->setParameter(overlay_dev, overlay,
  683
+                              OVERLAY_COLOR_KEY,-1); //here -ve value is to disable colorkey
  684
+    }
  685
+    else
  686
+    {
  687
+        overlay_dev->setParameter(overlay_dev, overlay,
  688
+              OVERLAY_COLOR_KEY, 0x00); //enabling black color key
  689
+    }
  690
+#endif
  691
+
609 692
     mOverlay = overlay;
610 693
     mWidth = overlay->w;
611 694
     mHeight = overlay->h;
... ...
@@ -615,6 +698,10 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
615 698
     mInitialized = false;
616 699
 
617 700
     mOverlayHandle = overlay->getHandleRef(overlay);
  701
+
  702
+#ifdef OMAP_ENHANCEMENT
  703
+    layer.dpy = 0; //initialize the Layer display ID to 0
  704
+#endif
618 705
     
619 706
     sp<OverlayChannel> channel = new OverlayChannel( &layer );
620 707
 
... ...
@@ -623,11 +710,72 @@ LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
623 710
     getFlinger()->signalEvent();
624 711
 }
625 712
 
  713
+#ifdef OMAP_ENHANCEMENT
  714
+LayerBuffer::OverlaySource::OverlaySource(LayerBuffer& layer,
  715
+        sp<OverlayRef>* overlayRef,
  716
+        uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D)
  717
+    : Source(layer), mVisibilityChanged(false),
  718
+    mOverlay(0), mOverlayHandle(0), mOverlayDevice(0), mOrientation(orientation)
  719
+{
  720
+    overlay_control_device_t* overlay_dev = mLayer.mFlinger->getOverlayEngine();
  721
+    if (overlay_dev == NULL) {
  722
+        // overlays not supported
  723
+        return;
  724
+    }
  725
+    mOverlayDevice = overlay_dev;
  726
+    overlay_t* overlay = overlay_dev->createOverlay_S3D(overlay_dev, w, h, format, isS3D);
  727
+    if (overlay == NULL) {
  728
+        // couldn't create the overlay (no memory? no more overlays?)
  729
+        return;
  730
+    }
  731
+
  732
+    // enable dithering...
  733
+    overlay_dev->setParameter(overlay_dev, overlay,
  734
+            OVERLAY_DITHER, OVERLAY_ENABLE);
  735
+
  736
+    //get the graphic plane pixel format and decide whether to use color key
  737
+    //or per-pixel alpha blend
  738
+    PixelFormat pixfmt = mLayer.mFlinger->getFormat();
  739
+    if ((pixfmt == PIXEL_FORMAT_RGBA_8888) || (pixfmt == PIXEL_FORMAT_BGRA_8888) || \
  740
+     (pixfmt == PIXEL_FORMAT_RGBA_5551) || (pixfmt == PIXEL_FORMAT_RGBA_4444))
  741
+    {
  742
+         overlay_dev->setParameter(overlay_dev, overlay,
  743
+                              OVERLAY_COLOR_KEY,-1); //here -ve value is to disable colorkey
  744
+    }
  745
+    else
  746
+    {
  747
+        overlay_dev->setParameter(overlay_dev, overlay,
  748
+              OVERLAY_COLOR_KEY, 0x00); //enabling black color key
  749
+    }
  750
+
  751
+    mOverlay = overlay;
  752
+    mWidth = overlay->w;
  753
+    mHeight = overlay->h;
  754
+    mFormat = overlay->format;
  755
+    mWidthStride = overlay->w_stride;
  756
+    mHeightStride = overlay->h_stride;
  757
+    mInitialized = false;
  758
+
  759
+    mOverlayHandle = overlay->getHandleRef(overlay);
  760
+
  761
+    layer.dpy = 0; //initialize the Layer display ID to 0
  762
+
  763
+    sp<OverlayChannel> channel = new OverlayChannel( &layer );
  764
+
  765
+    *overlayRef = new OverlayRef(mOverlayHandle, channel,
  766
+            mWidth, mHeight, mFormat, mWidthStride, mHeightStride);
  767
+    mLayer.mFlinger->signalEvent();
  768
+}
  769
+#endif
  770
+
626 771
 LayerBuffer::OverlaySource::~OverlaySource()
627 772
 {
628 773
     if (mOverlay && mOverlayDevice) {
629 774
         overlay_control_device_t* overlay_dev = mOverlayDevice;
630 775
         overlay_dev->destroyOverlay(overlay_dev, mOverlay);
  776
+#ifdef OMAP_ENHANCEMENT
  777
+        mOverlay = 0;
  778
+#endif
631 779
     }
632 780
 }
633 781
 
... ...
@@ -654,6 +802,36 @@ void LayerBuffer::OverlaySource::onvalidateVisibility(const Transform&)
654 802
     mVisibilityChanged = true;
655 803
 }
656 804
 
  805
+#ifdef OMAP_ENHANCEMENT
  806
+void LayerBuffer::OverlaySource::setDisplayId(int displayId) {
  807
+    if (UNLIKELY(mOverlay != 0)) {
  808
+        // we need a lock here to protect "destroy"
  809
+        Mutex::Autolock _l(mOverlaySourceLock);
  810
+        if (mOverlay) {
  811
+            overlay_control_device_t* overlay_dev = mOverlayDevice;
  812
+            mLayer.dpy = displayId;
  813
+            overlay_dev->setParameter(overlay_dev, mOverlay,
  814
+                                    OVERLAY_SET_SCREEN_ID, mLayer.dpy);
  815
+            overlay_dev->commit(overlay_dev, mOverlay);
  816
+        }
  817
+    }
  818
+}
  819
+
  820
+int LayerBuffer::OverlaySource::requestOverlayClone(bool enable) {
  821
+    if (UNLIKELY(mOverlay != 0)) {
  822
+        //we need a lock here to protect "destroy"
  823
+        Mutex::Autolock _l(mOverlaySourceLock);
  824
+        if (mOverlay) {
  825
+            overlay_control_device_t* overlay_dev = mOverlayDevice;
  826
+            int overlayclonefd = overlay_dev->requestOverlayClone(overlay_dev, mOverlay, (int)enable);
  827
+            return overlayclonefd;
  828
+        }
  829
+    }
  830
+    return (-1);
  831
+}
  832
+
  833
+#endif
  834
+
657 835
 void LayerBuffer::OverlaySource::onVisibilityResolved(
658 836
         const Transform& planeTransform)
659 837
 {
... ...
@@ -680,6 +858,16 @@ void LayerBuffer::OverlaySource::onVisibilityResolved(
680 858
                         Transform(mOrientation));
681 859
                 overlay_dev->setParameter(overlay_dev, mOverlay,
682 860
                         OVERLAY_TRANSFORM, finalTransform.getOrientation());
  861
+#ifdef OMAP_ENHANCEMENT
  862
+                //get the current state of the layer: to commit the latest parameters
  863
+                State& layerSt = mLayer.currentState();
  864
+                overlay_dev->setParameter(overlay_dev, mOverlay,
  865
+                        OVERLAY_PLANE_ALPHA, layerSt.alpha);
  866
+                overlay_dev->setParameter(overlay_dev, mOverlay,
  867
+                        OVERLAY_PLANE_Z_ORDER, layerSt.z);
  868
+                overlay_dev->setParameter(overlay_dev, mOverlay,
  869
+                OVERLAY_SET_SCREEN_ID, mLayer.dpy);
  870
+#endif
683 871
                 overlay_dev->commit(overlay_dev, mOverlay);
684 872
             }
685 873
         }
Txt services/surfaceflinger/LayerBuffer.h
... ...
@@ -49,6 +49,10 @@ class LayerBuffer : public LayerBaseClient
49 49
         virtual void unregisterBuffers();
50 50
         virtual void destroy() { }
51 51
         SurfaceFlinger* getFlinger() const { return mLayer.mFlinger.get(); }
  52
+#ifdef OMAP_ENHANCEMENT
  53
+        virtual void setDisplayId(int dpy);
  54
+        virtual int requestOverlayClone(bool enable);
  55
+#endif
52 56
     protected:
53 57
         LayerBuffer& mLayer;
54 58
     };
... ...
@@ -75,7 +79,13 @@ public:
75 79
     void unregisterBuffers();
76 80
     sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format,
77 81
             int32_t orientation);
78  
-    
  82
+#ifdef OMAP_ENHANCEMENT
  83
+    sp<OverlayRef> createOverlay(uint32_t w, uint32_t h, int32_t format,
  84
+            int32_t orientation, int isS3D);
  85
+
  86
+    void setDisplayId(int displayId);
  87
+    int requestOverlayClone(bool enable);
  88
+#endif
79 89
     sp<Source> getSource() const;
80 90
     sp<Source> clearSource();
81 91
     void setNeedsBlending(bool blending);
... ...
@@ -151,6 +161,14 @@ private:
151 161
         OverlaySource(LayerBuffer& layer,
152 162
                 sp<OverlayRef>* overlayRef, 
153 163
                 uint32_t w, uint32_t h, int32_t format, int32_t orientation);
  164
+
  165
+#ifdef OMAP_ENHANCEMENT
  166
+        OverlaySource(LayerBuffer& layer,
  167
+                sp<OverlayRef>* overlayRef,
  168
+                uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D);
  169
+        virtual void setDisplayId(int dpy);
  170
+        int requestOverlayClone(bool enable);
  171
+#endif
154 172
         virtual ~OverlaySource();
155 173
         virtual void onDraw(const Region& clip) const;
156 174
         virtual void onTransaction(uint32_t flags);
... ...
@@ -203,6 +221,13 @@ private:
203 221
         
204 222
         virtual sp<OverlayRef> createOverlay(
205 223
                 uint32_t w, uint32_t h, int32_t format, int32_t orientation);
  224
+
  225
+#ifdef OMAP_ENHANCEMENT
  226
+        virtual sp<OverlayRef> createOverlay(
  227
+                uint32_t w, uint32_t h, int32_t format, int32_t orientation, int isS3D);
  228
+        virtual void setDisplayId(int displayId);
  229
+        virtual int requestOverlayClone(bool enable);
  230
+#endif
206 231
     private:
207 232
         sp<LayerBuffer> getOwner() const {
208 233
             return static_cast<LayerBuffer*>(Surface::getOwner().get());
Txt services/surfaceflinger/SurfaceFlinger.cpp
... ...
@@ -152,6 +152,13 @@ overlay_control_device_t* SurfaceFlinger::getOverlayEngine() const
152 152
     return graphicPlane(0).displayHardware().getOverlayEngine();
153 153
 }
154 154
 
  155
+#ifdef OMAP_ENHANCEMENT
  156
+PixelFormat SurfaceFlinger::getFormat() const
  157
+{
  158
+    return graphicPlane(0).displayHardware().getFormat();
  159
+}
  160
+#endif
  161
+
155 162
 sp<IMemoryHeap> SurfaceFlinger::getCblk() const
156 163
 {
157 164
     return mServerHeap;
... ...
@@ -410,7 +417,9 @@ bool SurfaceFlinger::threadLoop()
410 417
 
411 418
 #ifdef USE_COMPOSITION_BYPASS
412 419
         if (handleBypassLayer()) {
  420
+#ifndef OMAP_ENHANCEMENT
413 421
             unlockClients();
  422
+#endif
414 423
             return true;
415 424
         }
416 425
 #endif
Txt services/surfaceflinger/SurfaceFlinger.h
... ...
@@ -227,6 +227,9 @@ public:
227 227
     void destroyLayer(LayerBase const* layer);
228 228
 
229 229
     sp<Layer> getLayer(const sp<ISurface>& sur) const;
  230
+#ifdef OMAP_ENHANCEMENT
  231
+    PixelFormat getFormat() const;
  232
+#endif
230 233
 
231 234
 private:
232 235
     friend class Client;

0 notes on commit 1a6862f

Comments are parsed with GitHub Flavored Markdown

Commit_comment_tip

Tip: You can also add notes to lines in a file. Hover to the left of a line to make a note

Email notifications for these commit notes are on. Disable email notifications for this commit

Markdown Cheat Sheet

Format Text

Headers

# This is an <h1> tag
## This is an <h2> tag
###### This is an <h6> tag

Text styles

*This text will be italic*
_This will also be italic_
**This text will be bold**
__This will also be bold__

*You **can** combine them*

Lists

Unordered

* Item 1
* Item 2
  * Item 2a
  * Item 2b

Ordered

1. Item 1
2. Item 2
3. Item 3
   * Item 3a
   * Item 3b

Miscellaneous

Images

![GitHub Logo](/images/logo.png)
Format: ![Alt Text](url)

Links

http://github.com - automatic!
[GitHub](http://github.com)

Blockquotes

As Kanye West said:
> We're living the future so
> the present is our past.

Code Examples in Markdown

Syntax highlighting with GFM

```javascript
function fancyAlert(arg) {
  if(arg) {
    $.facebox({div:'#foo'})
  }
}
```

Or, indent your code 4 spaces

Here is a Python code example
without syntax highlighting:

    def foo:
      if not bar:
        return true

Inline code for comments

I think you should use an
`<addr>` element here instead.